From 67f93d6506320888e7d20fc698800e4151c69b74 Mon Sep 17 00:00:00 2001 From: getPL <47267794+getPL@users.noreply.github.com> Date: Sun, 3 Feb 2019 12:58:54 +1000 Subject: [PATCH] Update Main.java --- src/flashcards/Main.java | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/flashcards/Main.java b/src/flashcards/Main.java index d1b036c..2e8a45e 100644 --- a/src/flashcards/Main.java +++ b/src/flashcards/Main.java @@ -1,7 +1,33 @@ package flashcards; +import java.util.Scanner; public class Main { public static void main(String[] args) { - System.out.print("Hello world!"); + Scanner sc = new Scanner(System.in); + + System.out.println("Input the number of cards: "); + int n = sc.nextInt(); + int i; + String possible = sc.nextLine(); + String[] questions = new String[n]; + String[] answers = new String[n]; + + for (i = 0; i < n; i++) { + System.out.println("The card #" + (i+1) + ":"); + questions[i] = sc.nextLine(); + System.out.println("The definition of the card #" + (i+1) + ":"); + answers[i] = sc.nextLine(); + } + + for (i = 0; i < n; i++) { + System.out.println("Print the definition of \"" + questions[i] + "\":"); + possible = sc.nextLine(); + if (possible.equalsIgnoreCase(answers[i])) { + System.out.print("Correct answer. "); + } else { + System.out.println("Wrong answer (the correct one is \"" + answers[i] +"\")."); + } + } + } -} \ No newline at end of file +}