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

Update Main.java #66

Open
wants to merge 1 commit into
base: 03_07b
Choose a base branch
from
Open
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
23 changes: 17 additions & 6 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@

import java.util.Scanner;
public class Main {

public static void main(String args[]) {
String question = "";
String choiceOne = "";
String choiceTwo = "";
String choiceThree = "";
Scanner khervyn = new Scanner(System.in);
String question = "What is the capital of India?";
String choiceOne = "Mumbai";
String choiceTwo = "new delhi";
String choiceThree = "Kolkatta";

String correctAnswer = choiceTwo;

// Write a print statement asking the question
System.out.println(question);
// Write a print statement giving the answer choices

System.out.println("Options are :- \n (Mumbai , New Delhi , Kolkatta)");
// Have the user input an answer
System.out.print("Please input your answer => ");
String answer = khervyn.nextLine();
answer=answer.toLowerCase();
// Retrieve the user's input

// If the user's input matches the correctAnswer...
if(answer.equals(correctAnswer)){
System.out.println("Congratulations!!, You are right.");
}
else{
System.out.println("Wrong answer!! The correct answer is "+choiceTwo);
}
// then the user is correct and we want to print out a congrats message to the user.

// If the user's input does not match the correctAnswer...
Expand Down