본문 바로가기

java 코딩

다중 if문 계절입력

다중 if문을 이용하여 계절 입력시 결과값에 맞는 계절 출력하여라!!

 

 

 

import java.util.Scanner;
public class ex04_다중if문1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("월 입력 : ");
int month = sc.nextInt();
if(month==12||month==1||month==2) {
System.out.println(month +"월은 겨울입니다!");
}else if(month==3||month==4||month==5){
System.out.println(month + "월은 봄입니다!");
}else if(month==6||month==7||month==8){
System.out.println(month + "월은 여름입니다!");
}else if(month==9||month==10||month==11){
System.out.println(month + "월은 가을입니다!");
}else {
System.out.println("다시 입력해주세요");
}
}
}
view raw gistfile1.txt hosted with ❤ by GitHub

'java 코딩' 카테고리의 다른 글