초급JAVA 3 - 과제

voilà!·2021년 10월 31일
0

초급JAVA

목록 보기
6/24

탄수화물 중독 자가진단 테스트

	Scanner sc = new Scanner(System.in);
	int y = 0;
	String t1;
	
	System.out.println("======== 탄수화물 중독 자가진단 테스트 ========");
	
	System.out.println("아침을 배불리 먹은 후 점심시간 전에 배가 고프다 (Y/N)");
        t1 = sc.nextLine();
	if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("밥, 빵, 과자 등 음식을 먹기 시작하면 끝이 없다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("음식을 금방 먹은 후에도 만족스럽지 못하고 더 먹는다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("정말 배고프지 않더라도 먹을 때가 있다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("저녁을 먹고 간식을 먹지 않으면 잠이 오지 않는다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("스트레스를 받으면 자꾸 먹고 싶어진다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("책상이나 식탁 위에 항상 과자, 초콜릿 등이 놓여있다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("오후 5시가 되면 피곤함과 배고픔을 느끼고 일이 손에 안 잡힌다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("과자, 초콜릿 등 단 음식은 상상만해도 먹고 싶어진다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
	
	System.out.println("다이어트를 위해 식이조절을 하는데 3일도 못 간다 (Y/N)");
	 t1 = sc.nextLine();
     if(t1.equalsIgnoreCase("y")){
		++y;
	}
     
     if(7<=y){
    	 System.out.println("중독!");
     }else if(4 <= y && y <= 6){ //else if(y<=6){
    	 System.out.println("위험!");
     }else
    	 System.out.println("주의!");
     
   }
	
 }

0개의 댓글