83.5k views
2 votes
You have been asked to write a program that will ask the user for his or her pizza order and display it. The order will include the size of the pizza and the type of crust, cheese, and topping.

Input:

Ask the user what size pizza—small, medium, or large
Ask the user what type of crust
Ask the user what kind of cheese
Ask the user what topping
Output:

Print a message that clearly displays the user's pizza size, crust type, cheese type, and topping.
Write the complete program code below.

User YoavKlein
by
8.1k points

1 Answer

7 votes

Final answer:

Here is a sample program code that asks the user for their pizza order and displays it.

Step-by-step explanation:

Here is a sample program code that asks the user for their pizza order and displays it:

import java.util.Scanner;

public class PizzaOrder {

public static void main(String[] args) {
// Create a Scanner object
Scanner input = new Scanner(System.in);

// Ask the user for their pizza order
System.out.print("What size pizza (small, medium, or large)? ");
String size = input.nextLine();

System.out.print("What type of crust? ");
String crust = input.nextLine();

System.out.print("What kind of cheese? ");
String cheese = input.nextLine();

System.out.print("What topping? ");
String topping = input.nextLine();

// Print the user's pizza order
System.out.println("Your pizza order:");
System.out.println("Size: " + size);
System.out.println("Crust: " + crust);
System.out.println("Cheese: " + cheese);
System.out.println("Topping: " + topping);
}
}

User Jlabedo
by
8.4k points