Programming Problem Write a C++ program to input the number of tons from the use
ID: 3629430 • Letter: P
Question
Programming ProblemWrite a C++ program to input the number of tons from the user
and print out the equivalent in pounds, ounces, kilograms, and grams.
Also, print out the conversion factors used.
Declare all variables and constants as data type float.
You can input the number of tons from the user
based on the following instruction:
cin >> numberOfTons;
Header documentation and inline documentation must be included.
In order to demonstrate that your program works, you must collect the output as a script.
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
int main()
{double tons,lbs,ozs,kilo,grams;
cout<<"Note: ";
cout<<"2000 lbs = 1 ton ";
cout<<"16 oz in a lb ";
cout<<"1 lb=.45359237 kilo ";
cout<<"1 kilo=1000 grams ";
cout<<"Enter number of tons to convert: ";
cin>>tons;
lbs=tons*2000;
ozs=lbs*16;
kilo=lbs*.45359237;
grams=kilo*1000;
cout<<tons<<" tons= ";
cout<<lbs<<" pounds or ";
cout<<ozs<<" ounces or ";
cout<<kilo <<" kilograms or ";
cout<<grams<<" grams ";
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.