forked from Nnamdikeshi/Java2545examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDinner.java
More file actions
42 lines (28 loc) · 1.41 KB
/
Copy pathDinner.java
File metadata and controls
42 lines (28 loc) · 1.41 KB
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
35
36
37
38
39
40
41
package week1_variables_if_else;
import java.util.Scanner;
public class Dinner {
//Create two scanners, one for Strings, and one for numbers - int and float values.
//Use this scanner to read text data that will be stored in String variables
static Scanner stringScanner = new Scanner(System.in);
//Use this scanner to read in numerical data that will be stored in int or double variables
static Scanner numberScanner = new Scanner(System.in);
public static void main(String[] args) {
// Write your code between here...
System.out.println("What should we have for dinner?");
String dinnerSuggestion = stringScanner.nextLine();
//Computers only like pizza and tacos.
//So, print one response for pizza, another response one for tacos, and another response for anything else.
if (dinnerSuggestion.equalsIgnoreCase("pizza")) {
System.out.println("Pizza sounds good!");
} else if (dinnerSuggestion.equalsIgnoreCase("tacos")) {
System.out.println("Great! I like tacos");
} else {
System.out.println("How about pizza, or tacos?");
}
// ... and here.
// Close scanners. Good practice to clean up resources you use.
// Don't try to use scanners after this point. All code that uses scanners goes above here.
stringScanner.close();
numberScanner.close();
}
}