+ 1
C++ problem
Write a program that ask user about his weight and height to calculate the perfect weight (=height-100). The program should tells the user if his weight is perfect, or tells him whether he should loose or gain some kilograms and how much are these kilograms.
1 Answer
+ 11
double w = 0.0; // weight
double h = 0.0; // height
cout << "Weight = "; cin >> w;
cout << "Height = "; cin >> h;
if (w < h - 100 ) cout << "You need to add " << (h - 100) - w << " kg.";
else if (w == h - 100) cout << "everything is fine!";
else cout << "You need to loose " << w - (h - 100) << " kg.";