All pastes #546227 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-07 00:56 UTC
rendered paste body
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
    int choice;
    int widthspere;
    int widthrect;
    int radius;
    int length;
    int height;
    int pi;
    
    //The variables and formulas
    pi = 3.14;
    //Sphere is 4/3*pi*radius^2
    //width*height*length
    
    //The calculations
    cout << "Would you like the volume of a sphere or a rectangle?" << endl;
    cout << "Please enter 1 for a rectangle, 2 for a sphere, and 3 to exit" << endl;
    while (choice == 1,2)
    {
    cin >> choice;    
    if (choice == 1)
    {
               cout << "You have chosen a rectangle" << endl;
               cout << "Please enter the width of the rectangle" << endl;
               cin >> widthrect;
               cout << "The width of the rectangle is " << widthrect << endl;
               cout << "Please enter the length of the rectangle" << endl;
               cin >> length;
               cout << "The length of the rectangle is " << length << endl;
               cout << "Please enter the height of th rectangle" << endl;
               cin >> height;
               cout << "The height of the rectangle is " << height << endl;
               cout << "The total volume of the rectangle is " << widthrect*height*length << endl;
    }
    
    if (choice == 2)
    {
               cout << "You have chosen sphere" << endl;
               cout << "Please enter the radius of the sphere" << endl;
               cin >> radius;
               cout<<"The radius of the sphere is "<<radius<<endl;
               cout<<"The total volume of hte sphere is "<<(4/3)*pi*radius<<endl;
               }
    
    if (choice == 3)
    {
               return 0;
    }
    if (choice != 1,2,3)
    {
    return 0;
}
}
}