import java.util.Random; import java.util.Scanner; public class Terminology { public static void main(String[] args) { String name = null; String input; char repeat; do { int count = 1; do { Random generator = new Random(); String[] terminology = {"gland", "joint", "life", "cancer", "heart", "head", "cerebrum", "urinary bladder", "cell", "skin", "electricity", "brain", "intestines", "red", "stomach", "Knowledge", "woman", "blood", "liver"}; String[] answer = {"aden/o", "arthr/o", "bi/o", "carcin/o", "cardi/o", "cephal/o", "cerebr/o", "cyst/o", "cyt/o", "derm/o", "electr/o", "encephal/o", "enter/o", "erythr/o", "gastr/o", "gnos/o", "gynec/o", "hemat/o", "hepat/o"}; int n = terminology.length; int r = generator.nextInt(n); String term = terminology[r]; System.out.println("What is the combining form of " + term + "?"); Scanner sc; sc = new Scanner(System.in); name = sc.nextLine(); if (answer[r].equalsIgnoreCase(name)) { System.out.println("Thats right!" + "\n"); } else { System.out.println("Sorry thats wrong" + "\n" + ("The correct answer is " + answer[r] + "\n")); } count++; }while (count <=10); System.out.println("Would you like to test again? " + "Enter Y for yes or N for no: "); Scanner keyboard = new Scanner(System.in); input = keyboard.next(); repeat = input.charAt(0); }while(repeat == 'Y' || repeat == 'y'); } }
Thanks,
Kevin