forked from haonlywan/CodeHS-Java-APCSA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.9.6 Order Up!
34 lines (24 loc) · 1.01 KB
/
2.9.6 Order Up!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
public class PickupWindow
{
public static void main(String[] args)
{
// Create scanner object
Scanner input = new Scanner(System.in);
// Display menu
String menu = "1. Hamburger\n2. Cheeseburger\n3. Veggie Burger\n4. Nachos\n5. Hot Dog\n";
System.out.println(menu);
// Get customer order
System.out.println("Enter label: ");
String customerOrder = input.nextLine();
// Use substring to get the first character (the number)
String combo = customerOrder.substring(0, 1);
// Create an Integer object by using the static
// method Integer.valueOf(someString)
// to turn the string into an Integer
Integer comboNumber = Integer.valueOf(combo);
int i = comboNumber.intValue();
// Print out what the customer ordered
System.out.println("Customer ordered number " + comboNumber);
}
}