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"
1 Antwort
+ 6
double savings;
double expenditure;.
cin >> savings;
cin >> expenditure;
cout << "Solvent" << endl;
if (expenditure > savings)
{
cout << "Bankrupt" << endl;
}
else
{
savings = savings - expenditure;
}