Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

04 01b #16

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions learning-java-2825378.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added out/production/learning-java-2825378/Main.class
Binary file not shown.
37 changes: 37 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.Scanner;

public class Main {

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 correctAnswe = 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 the user's input matches the correctAnswer...
// then the user is correct and we want to print out a congrats message to the user.
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);
}
// If the user's input does not match the correctAnswer...
// then the user is incorrect and we want to print out a message saying that the user is incorrect as well as what the correct choice was.

}

}