Write an if-else statement for each of the problems below: a. Output the word Hi
ID: 3850554 • Letter: W
Question
Write an if-else statement for each of the problems below: a. Output the word High if the value in the variable score is greater than 100 and output the word Low if the value of the variable score is at most 100. b. Suppose you have two variables called savings and expenses that already contain a value. Write an if-else statement that does the following: That will output the word solvent, decreases the value of savings by the value of expenses, and sets the value of expenses to zero provided that savings is at least as large as expenses. If however, savings is less than expenses, the statement simply outputs the word Bankrupt and does not change the value of any variables.Explanation / Answer
a)solution:
if( score > 100)
cout << "High";
else
cout << "Low";
b)solution
if (savings >= expenses)
{
savings = savings - expenses;
expenses = 0;
cout <<"Solvent ";
}
else
{
cout <<" Bankrupt ";
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.