Question: Please use JAVA ;Integers numMangos and moneyOnHand are read from input. Each mango costs 3 dollars. Write the following if - else statement. Within the

Please use JAVA ;Integers numMangos and moneyOnHand are read from input. Each mango costs 3 dollars.
Write the following if-else statement. Within the else branch, write the following assignment and nested if-else statement:
If numMangos is less than 5, output "Please purchase at least 5 mangos".
Otherwise:
Assign variable totalCost with the product of numMangos and 3.
If totalCost is less than or equal to moneyOnHand, then output "Mangos successfully purchased".
Otherwise, output "Not enough money to buy all".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!