0

If - else statement

Suppose savings and expenditure are variables of type double. Write an if-else statement that requests two inputs from the user and outputs the word "Solvent", decreases the value of savings by the value of expenditure to zero, provided savings is at least greater than the expenditure. If however, savings is less than expenditure, the program should output the word "Bankrupt"

7th Feb 2017, 12:57 PM
grace barnoh
grace barnoh - avatar
1 Antwort
+ 6
double savings; double expenditure;. cin >> savings; cin >> expenditure; cout << "Solvent" << endl; if (expenditure > savings) { cout << "Bankrupt" << endl; } else { savings = savings - expenditure; }
7th Feb 2017, 3:16 PM
Hatsy Rei
Hatsy Rei - avatar