A metric ton is 35,273.92 ounces. Write a program that will read the weight of a package of breakfast cereal in ounces and output the weight in metric tons as well as the number of boxes needed to yield one metric ton of cereal. Your program should allow the user to repeat this calculation as often as the user wishes.
Program Code:
//Header file
#include <iostream>
using namespace std;
//main function
int main ( )
{
//Variables declaration
double const METRIC_TON = 35273.92;
double ounce,boxes;
double weight;
double numOfBoxex;
//Prompt and read the input from the keyboard
cout<<"Enter the weight of a package of breakfast
cereal in ounces:";
cin>>ounce;
//Calculate the weight in metric tons and display it
weight = ounce/METRIC_TON;
cout<<"The weight of the cereal: "<<weight<<endl;
//Calculate the the number of boxes needed to yield one
//metric ton of cereal and display it
numOfBoxex = METRIC_TON/ounce;
cout<<"The number of boxes of cereal that will hold
a ton: "<<numOfBoxex<<endl;
return 0;
}
Output:
Enter the weight of a package of breakfast cereal in ounces:100
The weight of the cereal: 0.00283496
The number of boxes of cereal that will hold a ton: 352.739