I am wanting to add more math functions to this prog.
As I said I'm a noobie(learning c++ 6 mo's )
I am starting to learn pointers / arrays and need help.
any way to simplify and make program flow better
Thanks
Code:
#include<iostream>
int main()
{
int area, volume, height, width, length, sphere, circ, vols, pi, done, y, n ;
bool finished = true; // ADDED THIS: will hold true if finished else it will hold false
char temp = '\0'; // Used for user input, set to empty.
pi = 3.14159265; //make pi=to value
do //start do loop
{
std::cout<<"\nDo you wish to calculate Area or Volume or vol of Sphere?(A/V/S)";
char avs; //int chars a v and s
std::cin>>avs; //input one of the three
if (avs == 'a') //if input=this do the below then goto the end
{
//input and calculate area
std::cout<<"\ninput width in inches:";
std::cin>>width;
std::cout<<"\ninput length in inches:";
std::cin>>length;
area=length*width; //formula for context
std::cout<<"\narea is:";
std::cout<<area;
std::cout<<" Square Inches\n";
}
else if (avs == 'v') //if input=this do the below then goto the end
{
//input and calculate volume
std::cout<<"\ninput width in inches:";
std::cin>>width;
std::cout<<"\ninput height in inches:";
std::cin>>height;
std::cout<<"\ninput length in inches:";
std::cin>>length;
volume=height*width*length; //formula for context
std::cout<<"\nvolume is:";
std::cout<<volume;
std::cout<< " Cubic Inches\n";
}
else if (avs == 's') //if input=this do the below then goto the end
{
//input and calculate circumfrence
std::cout<<"\n input diameter/2 or radius";
std::cin>>sphere;
vols = 4*pi*(sphere*sphere); //formula for context
circ = (2*sphere)*pi; //formula for context
std::cout<<"\narea is:";
std::cout<<vols;
std::cout<< "Cubic inches";
std::cout<<"\nby the way the circumfrence is";
std::cout<<circ;
std::cout<< " Inches\n";
}
// Does the user wish to continue or quit?
std::cout<<"\nDo you want to quit? (Y)es or (N)o?";
std::cin >> temp;
if(temp == 'n' || temp == 'N')
done = false;
else if(temp == 'y' || temp == 'Y')
done = true;
else
{
std::cout << "Invalid Input...";
return 0;
}
} while(!done)
;
return 0;
//end of volarea2,1.cpp
}