Question: if ( numSalads < 6 ) { System.out.println ( Please purchase at least 6 . ) ; } else { / / Calculate

if (numSalads <6){
System.out.println("Please purchase at least 6.");
} else {
// Calculate total cost if numSalads is greater than or equal to 6
totalCost = numSalads *4;
// Check if totalCost is within budget
if (totalCost <= myMoney){
System.out.println("Successful purchase!");
// Check if at least one item was purchased
if (myMoney >=4){
System.out.println("At least one item was purchased.");
}
// Check if numSalads is greater than 27
if (numSalads >27){
System.out.println("Restocking soon.");
}
} else {
System.out.println("Not all salads purchased.");
}
}

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 Databases Questions!