-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDebuggingDebugger.java
More file actions
35 lines (26 loc) · 1.12 KB
/
Copy pathDebuggingDebugger.java
File metadata and controls
35 lines (26 loc) · 1.12 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
// This is the starter code snippet with bugs.
// Follow the notebook to finish it up!
import java.util.Scanner;
public class DebuggingDebugger {
public static void main(String args[]) {
String question = "What is the largest planet in our solar system?";
String choiceOne = "earth";
String choiceTwo = "jupiter";
String choiceThree = "saturn";
String correctAnswer = choiceThree;
// Write a print statement asking the question
System.out.println(question);
// Write a print statement giving the answer choices
System.out.println("Choose one of the following: " +
choiceOne + ", " + choiceTwo + ", or " + choiceThree + ".");
// Have the user input an answer
Scanner scanner = new Scanner(System.in);
// Retrieve the user's input
String input = scanner.next();
if(correctAnswer.equals(input.toLowerCase())) {
System.out.println("Congrats! That's the correct answer");
} else {
System.out.println("You are incorrect. The correct answer is " + correctAnswer);
}
}
}