From e2adb882984749be8e197b2005b894fa97c6cd0f Mon Sep 17 00:00:00 2001 From: Khervyn Gupta <88488547+Khervyngupta@users.noreply.github.com> Date: Tue, 20 Sep 2022 20:48:47 +0530 Subject: [PATCH] Update Main.java --- src/Main.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Main.java b/src/Main.java index 4b88cab2..a690e5fc 100644 --- a/src/Main.java +++ b/src/Main.java @@ -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...