Skip to content

Instantly share code, notes, and snippets.

@tsuzukihashi
Created July 7, 2017 16:19
Show Gist options
  • Save tsuzukihashi/22e71a3ca527e45737078c2ca1ba0646 to your computer and use it in GitHub Desktop.
Save tsuzukihashi/22e71a3ca527e45737078c2ca1ba0646 to your computer and use it in GitHub Desktop.
package chap06;
import java.util.Random;
import java.util.Scanner;
class Ex614 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
Random rand = new Random();
String[] monthString = {"January","Feburary","March","April","May","June",
"July","August","September","October","November","December"
};
int num = 0;
System.out.println("英語の月名を入力してください");
System.out.println("なお、先頭は大文字で、2文字目以降は小文字とします。");
do {
int month = rand.nextInt(12);
while(true) {
System.out.print(month+1+"月:");
String m = stdIn.next();
if(monthString[month].equals(m))
break;
else
System.out.println("違います。");
}
System.out.println("正解です。");
System.out.print("もう一度?1...Yes/0...No :");
num = stdIn.nextInt();
}while(num==1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment