JAVA예제2010. 9. 13. 10:27
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: moonleaf
 * Date: 2010. 9. 13
 * Time: 오전 9:25:13
 * To change this template use File | Settings | File Templates.
 */
public class Ex006 {
    public static void main(String[] args) {
        String[] data = {
                         "다음 중 키워드가 아닌 것은?`2`final`True`if`public",
                         "다음 중 자바의 연산자가 아닌 것은?`6`&`|`++`!=`/`^",
                         "다음 중 메서드의 반환값이 없음을 의미하는 키워드는?`1`void`null`false`",
                         };

        Scanner s = new Scanner(System.in);
        int score = 0;

        for(int i=0;i < data.length;i++) {
              String[] tmp = data[i].split("`",3);

              String question = tmp[0];
              String answer = tmp[1];
              String[] choices = tmp[2].split("`");

              System.out.println("["+(i+1)+"] "+question);

              for(int x=0;x < choices.length;x++) {
                    System.out.print((x+1)+"."+choices[x]+"\t");
              }
           
              System.out.println();

              System.out.print("[답]");
              String input = s.nextLine();
              if(input.equals(answer)){
                  score = score +1;
              }

              System.out.println();
              System.out.println();
        }


        System.out.print("정답개수/전체문항수 : "+ score + "/" + data.length );

    } // main

}


'JAVA예제' 카테고리의 다른 글

JAVA 예제 3-1  (0) 2010.09.13
JAVA 예제 2-3  (0) 2010.09.13
JAVA 예제 2-1  (0) 2010.09.10
JAVA 예제 1-4  (0) 2010.09.10
JAVA 예제 1-3  (0) 2010.09.10
Posted by 달빛낙엽