Hey there people. Im sure its a silly mistake but i cant get my while to work.
sorry to dump a large code in your faces
tell me off if you need to![]()
Code:#include <iostream.h> float FindVolume(int diameter,int length) { float pi = 3.14159265358979323846; float circumference = pi*diameter; float volume = circumference*length; return volume; } int SquareThisNumber(int number) { int SquaredNumber = number*number; return SquaredNumber; } int main() { int diameter; int length; int number; int choice; int exit = 0; while(exit==0); //Should loop because exit is specified as 0 above. //exit can only be changed by user input at end of program. { std::cout << "Choose what you want to do from the list below and enter the number" << std::endl; std::cout << "1)Square a Number" << std::endl; std::cout << "2)Find the Diameter of a Cylinder" << std::endl; std::cin >> choice; if(choice==1) { std::cout << "Please enter a number. I would love to square it." << std::endl; std::cin >> number; std::cout << number << " squared is: " << SquareThisNumber(number) << std::endl; } else if(choice==2) { std::cout << "Type the diameter of a cylinder" << std::endl; std::cin >> diameter; std::cout << "Type the length of a cylinder" << std::endl; std::cin >> length; std::cout << "Diameter: " << diameter << "cm" << std::endl; std::cout << "Length: " << length << "cm" << std::endl; std::cout << "The volume is " << FindVolume(diameter,length) << "cm3" << std::endl; } else { std::cout << "WTF! enter a number from the list above! foolish..."; } std::cout << "What would you like to do?" << std::endl; std::cout << "0)Back to menu" << std::endl; std::cout << "1)Exit Program" << std::endl; std::cin >> exit; } return 0; }
Thanks for taking the time to click my post![]()



LinkBack URL
About LinkBacks



