#include <iostream>
usingnamespace std;
int main()
{
float goal[4]; //array of 4 floating point numbers
goal[0]=0.9;
goal[1]=0.75;
goal[2]=0.5;
goal[0]=0.9; //sure that this shouldn't be goal[3] = 0.25?
float weight, target;
cout << "Enter Current Weight : "; //get data from the user and store it in relevant variables
cin >> weight; //for instance 20
cout << "Enter goal weight : ";
cin >> target; //for instance 10
cout << "\n";
for (int i=0; i<4; i++) //traversing the array, ie do the following for every element in goal[]
{
float loss = (weight - target)* goal[i]; // ie 20-10=10*0.5 = 5 (calculate how much is to be lost per goal
cout << "Goal : " << i << " : "; //print goal, ie 0.5
cout << weight - loss << "\n"; //print weight - loss, ie 20-5 = 15
}
return 0;
}
It basically asks the user for an initial weight and a target weight, then it displays 4 stages of loosing weight calculated according to the values in the goal[] array.
Design a program that will ask the user for his current weight and his target weight after weight loss.
Then display the target weight for every 4 phases of the weight-loss program, knowing that at the first phase a loss of 10% is expected, 25% at the second phase, 50% at the third, ... ?