C/C++ :: Circle Paper Of Radius R - Max Cone Volume
Jan 23, 2014
My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.
I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.
I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.
#include <iostream>
#include <cmath>
#include <iomanip>
#include <conio.h>
using namespace std;
const double PI = 3.1415;
int main() {
double rem_sec;
I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.
The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output. Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed. A value-returning function should be used because it's a little simpler to understand, but you can employ a void function. Need to have a function prototype at the top of the code, then main, then your function.
//Cone Volume Calculator Program #include <iostream> using namespace std; int main( ) { //Declare variables and constants double coneRadius = 0.0; double coneHeight = 0.0;
I am having trouble with calculating the volume of a cone
Assignment: Using the knowledge you already have, create, build, run, and correct if necessary a program that will calculate the volume of a cone. Insert into your code values for diameter of the base and the height. Use variables, constants, literals, and mathematics as necessary.
The formula for the volume is:
1/3 π x Radius2 x Height
Hint: you will need to add to your program two lines where appropriate:
#include <cmath> const double PI = 2*acos(0.0);
Here is my current code:
#include <iostream> using namespace std; int main () { //diameter of the base float diameter = 3;
Let (x,y) be the center of the circle. (x,y) will not be (0,0). I have radius of the circle. Now i want to find the angle and radius of the given point inside the circle.
what im trying to do is an option to play again. if the user decides to play again then i want the options to execute again and if the user choses not to play again then i want the game to show the scores.
here is what i have so far:
Code:
// Purpose: Play the Rock-Paper-Scissors-Lizard-Spock Game #define _CRT_SECURE_NO_WARNINGS #include <stdio.h>
I made a rock paper scissors game in c++. How to make it better, and what i can do differently
#include <iostream> #include <string> using namespace std;
int checkConvertInput(string signs[], int wins, int draws, int losses); void calculateWinner(int playerSign, string signs[], int &wins, int &draws, int &losses); void endResult(int wins, int draws, int losses);
I'm getting a error on my Circle::Circle(double radiusValue) constructor. My instructions is 'Add a constructor that accepts one argument and uses it to set the radius.'
#include <iostream> #include <cmath> using namespace std; class Circle { private: double x; double y; double radius;
Exerted by the rider's foot yet not exceed the stress placed on the crank arm's sprocket attachment, is provided by this formua:
r^3 = d*p/s*π
r is the radius of the cylindrical rod in inches. d is the length of the crank arm in inches. P is the weight placed on the pedal in lbs. S is the stress in lbs/in2
Using this information, design, write, compile, and execute a C++ program that computes the value of r for a crank arm that is 7 inches long, accommodates a maximum weight of 300 lbs, and is able to sustain a stress of 10,000 lbs/in2.
So , i had to make an rock paper scissors game . After lot of hard work and struggle ,I completed it but my professor rejected it since I didnot add option where it says "Would you like to play again .Y/N " . The code has too many brackets ! Here is my code
#include <iostream> #include <ctime> #include <cstdlib> using namespace std;
// for displaying the outputs to the user; passing string to functions void user_win() {
When i return 0; at the function int userselect (int user, int comp)my output displays twice and when i ask the user to run it again the computers selection of rock, paper or scissors remains the same it doesn't find a new random number. So i made the function userselect return to main(). This works and my output is displayed once, but when i run it it skips my while part of my do while loop completely so it loops the program without asking the user if they wish to run it again.
but when i return main() the computers choice re-randomizes every time so i need to find a way to get the while part of my do while to initialize and the program to not loop without the option of ending it.
-create a get and set for height, width, length. -A default parameterized constructor = 1 -A method to resize the box -A method to get the volume of the box -A method to convert the object to a string
My Questions:
The 3 parts I am confused by are the default parameter constructor, the re-size the box and the method to convert to string. For the default parameter part I figured making length, width and height = to 1 would work, but I'm pretty sure thats not what I'm supposed to do.
This is the main file
#include "box_class.h" #include <iostream> using namespace std; int main() { double length; double width; double height; double volume;
I run some computations which give a big number of vectors (let's say 100 vectors, each one contain 2000 elements of type double). I want to save those data and import them into Excel.
I know I can save the results through in txt file. But it would be a very long file. Can I save the results in other more efficient file form that can be imported into Excel? and how?
// DEBUG3-4 // This program contains a class for a cylinder // Data members are radius and height // The volume is calculated as pi times radius squared times height // If no height is given, it's not a cylinder - it's a circle!
#include<iostream> using namespace std; //declaration section
What I want to do with my program is I want my length, width,volume and price to accept number values only. This is what I have so far.
// This program calculates and displays the pool's volume // the amount of water needed and the cost.
#include <iostream> #include <iomanip> using namespace std; int main() { // the double type accepts numbers including fractions for the following inputs. double length, width, depth, poolvolume, watervolume, price;
In 2D I checked to see if a point was inside a shape by creating triangles between 2 neighbouring points and the centre of the object, then checking the angle to the 3 points from the test point and if the sum = 360... If not then it isn't inside the triangle. But how would I check if a point is inside a volume rather than an area? I know the same method would work but I don't think very well as it'll be testing with the thickness of the shell of the 3D object, which may be quite easily jumped in a single frame of movement..
So for my assignment, I have to write code to calculate the surface area and volume for a rectangular prism that involves the use of functions. I made the program without functions and it works perfectly but as I'm putting in the required functions, it conversely made it non-functional, ironically. How to call functions correctly and the online book we're using now is confusing me even more.
I am using matlab R2o11 in which the programming medium is c++. I am having these variables=
T=373 t0 376 V=0.09 to 1 P=T/V
I just need a result showing ... First it should take T=373 and solve the equation using all volume values. Then it takes another temperature and do the same.