Question: Create a public static Boolean field named detailedMode and initialize detailedMode with true. Ex: If the input is milk cream cheese, then the output is:

Create a public static Boolean field named detailedMode and initialize detailedMode with true.
Ex: If the input is milk cream cheese, then the output is:
The ordered food is milk.
The ordered food is cream.
Order: cheese public class Order {
/* Your code goes here */
private String food;
public Order(String newFood){
food = newFood;
}
public void print(){
if (detailedMode){
System.out.println("The ordered food is "+ food +".");
}
else {
System.out.println("Order: "+ food);
}
}
} NewOrders.java: import java.util.Scanner;
public class NewOrders {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
Order order1= new Order(scnr.next());
Order order2= new Order(scnr.next());
Order order3= new Order(scnr.next());
order1.print();
order2.print();
Order.detailedMode = false;
order3.print();
}
}

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!