The assignment is :

Write a C++ program that calculates the volume of 3 different geometric shapes. Your
program should give the user a menu like the following and repeat until the user wants to stop.
Volume Calculation Program
Select the Number of Your Chosen Object
1. Dumbbell
2. Axle
3. Spear
When the user selects one of the 3 objects, the program should then request the appropriate measurements (in inches) and then calculate and display the volume of that object. The result should be printed showing cubic-inch units with 3 decimals of precision.
Axle: 2 cylinders and a rod
Dumbbell: two spheres and a rod
Spears: two cones and a rod

Program requirements and Assumptions
Formulas and Abbr.
II P1 = 3.141 59
r radius
= height (or length)
Vol. of a sphere = 4I3flr3
Area of a circle = flr2
Vol. of a cylinder fl9b
Vol. of a cone = 1/3fJr2h
1. The rod-end fits against the dumbbell ball snugly; there is no “air-gap’. You may assume that there is no loss of volume of the ball when the rod is fitted against it.
2. The radius of the dumbbell and axle center rods cannot be larger than half the radius of the ball or wheel. Do not make calculations if the rod radius is more than half of the ball or wheel radius. Give the user an error message instead. For example, if the user enters a radius of 5 inches for the ball or wheel, the rod radius must be no larger than 2.5 inches.
3. The spear’s cone base has exactly the same radius as the connecting rod.
4. Output is to both the monitor and the printer.

This is so crazy, here is what I've got so far:

#include <cstring>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>

using namespace std;


int main()
{
	
	string Dumbell = '1';
	string Axel = '2';
	string Spear = '3';
	double radius, height, length, width, ball, rod, wheel, cone, vol;
	double pie = 3.14159;


	cout<<"Which shape are you working with"<<endl;
	cin>>'1' || '2' || '3';

	if (cin == 1)
	{

	cout<<"Please enter the radius (of ball), height, length of object & radius of rod"<<endl;
	cin>>radius>>height>>length>>rod;
	cout<<"Dumbell: "<<endl;
	cout<<"Radius of the ball: "<<radius<<endl;
	cout<<"Radius of the rod: "<<rod<<endl;
	cout<<"Length of rod: "<<heigth<<endl;
	vol = (4/3) * 3.142 * radius * radius * radius:
	cout<<"The volume of the dumbbell is "<<vol<<" "<<"cubic inches"<<endl;
	}

	else if (cin == 2)
	{
	cout<<"Please enter the radius of the wheel, radius of the rod, length of the rod, width of the wheel"<<endl;
	cin>>radius>>rod>>length>>width;
	cout<<"Axle: "<<endl;
	cout<<"Radius of the wheel: "<<radius<<endl;
	cout<<"Radius of the rod: "<<rod<<endl;
	cout<<"Length of the rod: "<<length<<endl;
	cout<<"Width of the wheel: "<<width<<endl;
	vol = ((pie * (radius *radius) * length) * 2)
	cout<<"The volume of the axel is "<<vol<<" "<<"cubic inches"<<endl;
	}

	else if (cin==3)
	{
	cout<<"Please enter the radius (of rod), the length of the rod & heigth of the cone"<<endl;
	cin>>radius>>length>>heigth;
	cout<<"Spear: "<<endl;
	cout<<"Radius of the rod: "<<radius<<endl;
	cout<<"Length of the rod: "<<length<<endl;
	cout<<"Height of the cone: "<<heigth<<endl;
	vol = (1/3 * pie * (radius * radius) * height) * 2;
	cout<<"The volume of the spear is "<<vol<<" "<<"cubic inches"<<endl;

	


	return 0;
}

Thx for assistance in advance.

Hai iam new to this can u help me regarding projects.I want to gain knowledge on c projects what should i do.
Please can u suggest me what should i do

Thanks & Regards,

Comments
needs to read forum rules

narsharma14....a few things:
1. Introduce yourself in the Geek lounge.
2. If you have a specific problem-post the code(not on my thread) and the guys here will take a look at it and help you.
3. Daniweb provides tutorials on several topics. You can go to goofle and search for a specific topic or the tutorials here (which are good).
4. Don't post your personal code/question on someone elses thread unless it's related to the orignal question...you need to start your own thread.
5. Don't post questions and expect an answer right away or any assistance if you don't try. We're all here to help you learn (even though I don't know a lot either)..
6. I reccommend taking a look at the Rules & FAQ for the daniweb forum.

Thanks.

The assignment is :

This is so crazy, here is what I've got so far:

So what is it you need help with? You need to ask a question so we know what you need help with. Just posting unfinished code and the assignment says "finish this for me, please".

So what's the problem?

One thing I did notice, though, 1/3 is 0, not .33333. But 1.0/3 will work.

#include <cmath>
#include <fstream>
#include <string>
#include <iostream>

using namespace std;



int main()
{

	int a,b,c;
	int ht = 0;//height
	int radB = 0;//radius of sphere
	int radR = 0;//radius of rod
	int radC = 0;//radius cone
	int wt = 0;//width
	int lt = 0;//length
	int wh = 0;//radius of wheel
	const double pie = 3.14159;//pie
	double volsp = (4.0/3) * (radB * radB * radB) * pie;//volume of a sphere
	double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
	double volcn = (1.0/3) * (radC * radC) * pie * ht;//volume of cone

	cout << "Do you want the volume of:\n";
	cout << "1. Dumbbell \n";
	cout << "2. Axle \n";
	cout << "3. Spear \n";

	cin >> a;
	    switch (a)
	    {
			case 1:
			cout<<"Enter radius of Sphere ";
			cin>>radB;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			float dumbbell = (volcy) + (volsp * 2);
			cout<<"The volume of the dumbbell is "<<dumbbell<<" cubic inches"<<endl;
		}

	cin >>b;
		switch (b)
		{
			case 2:
			cout<<"Enter radius of wheel ";
			cin>>wh;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter width of wheel ";
			cin>>wt;

			
			cout<<"The volume of the axle is "<<axle<<" cubic inches"<<endl;
		}

	cin >> c;
		switch (c)
		{
			case 3:
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter height of cone ";
			cin>>ht;

			
			cout<<"The volume of the spear is "<<spear<<"cubic inches"<<endl;
		}
				
	return 0;
}

Ok, so i made a bit of revision to my previous post. A few things:
1. I tried finding the volume of the Dumbbell(option 1) and it shows the result as being zero.
2. How to modify the program so that after the user calcualtes the volume of one object the program automatically goes back to the menu?
3. I'm kinna lost as how to calcualte the volume of the axle and spear.

Thx much for all the assistance.

#include <cmath>
#include <fstream>
#include <string>
#include <iostream>

using namespace std;



int main()
{

	int a,b,c;
	double ht = 0;//height
	double radB = 0;//radius of sphere
	double radR = 0;//radius of rod
	double radC = 0;//radius cone
	double wt = 0;//width
	double lt = 0;//length
	double wh = 0;//radius of wheel
	const double pie = 3.14159;//pie
	double volsp = (4.0/3) * (radB * radB * radB) * pie;//volume of a sphere
	double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
	double volcn = (1.0/3) * (radC * radC) * pie * ht;//volume of cone
	char again = 'y';

	cout << "Do you want the volume of:\n";
	cout << "1. Dumbbell \n";
	cout << "2. Axle \n";
	cout << "3. Spear \n";

	while (again == 'y')
	{
	cin >> a;
	    switch (a)
	    {
			case 1:
			cout<<"Enter radius of Sphere ";
			cin>>radB;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			double volsp = (4.0/3) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3) * (radC * radC) * pie * ht;//volume of cone
			double dumbbell = (volcy) + (volsp * 2);
			cout<<"The volume of the dumbbell is "<<dumbbell<<" cubic inches"<<endl;
			break;
		}

	cin>>b;
		case 2:
		{			
			cout<<"Enter radius of wheel ";
			cin>>wh;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter width of wheel ";
			cin>>wt;
			double volsp = (4.0/3) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3) * (radC * radC) * pie * ht;//volume of cone
			double axle = (volsp * 3);
			cout<<"The volume of the axle is "<<axle<<" cubic inches"<<endl;
			break;
		}

	cin >> c;
		case 3: 
		{		
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter height of cone ";
			cin>>ht;
			double volsp = (4.0/3) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3) * (radC * radC) * pie * ht;//volume of cone
			double spear = (volcn * 3);
			cout<<"The volume of the spear is "<<spear<<"cubic inches"<<endl;
			break;

		}
	       cout << "\n Do you want to try again? (y/n): ";
           cin >> again;
}
				
	return 0;
}

I did a bit of modifications and it's now saying that my case statement's are illegal and i'm getting the wrong output as my answers.

> Axle: 2 cylinders and a rod
> Dumbbell: two spheres and a rod
> Spears: two cones and a rod
First off, I would expect to see 4 functions along the lines of
double calculateSphereVolume( double radius );
double calculateRodVolume( double radius, double length );

Each of your cases then calls the functions with the appropriate parameters, say for axle
result = 2*calculateCylinderVolume() + calculateRodVolume();

i'd love to use functions, howver, we haven't reached that section, so our professor won't accept any work with functions.

I'm not really sure how to modify the program so that after the user calcualtes the volume of one object the program automatically goes back to the menu?

>> it's now saying that my case statement's are illegal

It looks like you're missing a }.


>>how to modify the program so that after the user calcualtes the volume of one object the program automatically goes back to the menu

Put the menu lines inside the while loop, before the switch statement. Be sure this:

cout << "\n Do you want to try again? (y/n): ";
cin >> again;

is outside the switch statement but inside the whhile loop.

Ok thx for your prompt reply, im also having a bit of problems with te calcualtions, after the corrections i'll submit my new code.

I did the modifications:

#include <cmath>
#include <fstream>
#include <string>
#include <iostream>

using namespace std;



int main()
{

	int a;//variable for switch statement
	double ht = 0.0;//height
	double radB = 0.0;//radius of sphere
	double radR = 0.0;//radius of rod
	double radC = 0.0;//radius cone
	double wt = 0.0;//width
	double lt = 0.0;//length
	double wh = 0.0;//radius of wheel
	const double pie = 3.14159;//pie
	double volsp = (4.0/3.0) * (radB * radB * radB) * pie;//volume of a sphere
	double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
	double volcn = (1.0/3.0) * (radC * radC) * pie * ht;//volume of cone
	char again = 'y';


	while (again == 'y')
	{
	cout << "Do you want the volume of:\n";
	cout << "1. Dumbbell \n";
	cout << "2. Axle \n";
	cout << "3. Spear \n";

	
	{

		cin>>a;
		switch(a){
				case 1:	
			cout<<"Enter radius of Sphere ";
			cin>>radB;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			double volsp = (4.0/3.0) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3.0) * (radC * radC) * pie * ht;//volume of cone
			double dumbbell = (volcy) + (volsp * 2.0);
			cout<<"The volume of the dumbbell is "<<dumbbell<<" cubic inches"<<endl;
			break;
			
		}

		
		cin>>b;
				
			case 2:
				{
			cout<<"Enter radius of wheel ";
			cin>>wh;
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter width of wheel ";
			cin>>wt;
			double volsp = (4.0/3.0) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3.0) * (radC * radC) * pie * ht;//volume of cone
			double axle = (volsp * 3.0);
			cout<<"The volume of the axle is "<<axle<<" cubic inches"<<endl;
			break;
			
		}	
		
		cin>>c;
				{	
			case 3:
			cout<<"Enter radius of rod ";
			cin>>radR;
			cout<<"Enter length of rod ";
	        cin>>lt;
			cout<<"Enter height of cone ";
			cin>>ht;
			double volsp = (4.0/3.0) * (radB * radB * radB) * pie;//volume of a sphere
			double volcy = pie * (radR * radR) * ht;//volume of cylinder/rod
			double volcn = (1.0/3.0) * (radC * radC) * pie * ht;//volume of cone
			double spear = (volcn * 3.0);
			cout<<"The volume of the spear is "<<spear<<"cubic inches"<<endl;
			break;
		}
		}
		
		
	       cout << "\n Do you want to try again? (y/n): ";
           cin >> again;
}
	
			
	return 0;
}

Problems
1. It's still saying that the cases are illegal.
2. Before the modifications, i was able to do the calculations for option 1, but wehn i tried for options 2 & 3, nothing woukld happen.
3. A dumbbell consists of two spheres and a cylinder. What is it that i'm overlooking. If i use the following info for dumbbell: radius of ball = 17. radius of the rod = 7. length of rod = 13. My professor said the answer should be 43160.211, however i get 41159...Thanx.

while (again == 'y')
{
  cout << "3. Spear \n";

  { //drop this 
		
  cin>>a;
		
  switch(a)
  {				
    case 1:
    //put a { here	
		
    cin>>b;  //drop this
    case 2: //this section was fine				
    cin>>c;  //drop this
    {	     //drop this

    case 3:
    //put a { here
		
  } //this is the end of the switch statement
  cout << "\n Do you want to try again? (y/n): ";
  cin >> again;
} //this is the end of the while loop

Ok....got it, thx very much for your assistance...all i have to do now is redo the mathematical part of the program which is giving me a pain. Thx again...i'm almost there.

This question has already been answered. Start a new discussion instead.