Conversion of Weight from Kg to Pound with use of Setprecision

08:12 3 Comments A+ a-

Problem:
Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram = 2.2 pounds.) Format your output with two decimal places.
Solution:
# include <iostream> # include <iomanip> using namespace std; int main() { double weight; double poundWeight; cout<<"Enter the weight in kilogram"<<endl; cin>>weight; poundWeight=(weight*2.2); cout<<"The weight in kilograms is:"<<setprecision(2)<<fixed<<weight<<endl; cout<<"The weight in pounds is:"<<setprecision(2)<<poundWeight<<endl; return 0; }

3 comments

Write comments
Unknown
AUTHOR
2 September 2020 at 15:03 delete

the code doesn't it says that the statements are not statements because of the "<<"

Reply
avatar