I'm doing this question which asks that the program above allows a user to repeat this calculation as often as a user wishes.Code://File name: PP1Ch2-cereal-weight //Description: a) A program to weight in ounces and output it in tons. // b) The number of boxes needed to yield a ton of cereal. //Last update: 21/7/2003 #include <iostream.h> #include <stdlib.h> int main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(4); double package_weight, package_weight_ton, number_of_packages; cout << "Enter the weight of a cereal package in ounces: "; cin >> package_weight; // A ton is 35723.92 oz. package_weight_ton = package_weight / 35273.92; number_of_packages = 1 / (package_weight / 35273.92); cout << "The weight of the package in tons is: " << package_weight_ton << " tons.\n"; cout.precision(1); cout << "A number of " << number_of_packages << " packages are needed to satisfy a ton of cereal.\n"; system("PAUSE"); return 0; }
That's instead of press any key to continue and then the program exits, the program should prompt again for user input when the user presses a key to continue.
Do I need to use if-else statements here? If so where should I put them?
Thanx.