나이가 저장된 변수가있습니다.
나이가 8~19이면 1000원
20~65이면 2000원
나머지는 무료!
라고 출력해주세요
package dayTest01;
public class Test04 {
public static void main(String[] args) {
/*
월이 저장된 데이터(==변수)가 있습니다.
3,4,5 봄
6,7,8 여름
9,10,11 가을
12,1,2 겨울
*/
int month=4; // 월이 저장된 변수
String season; // 문자열 season 변수
if(month>0 && month<13) { // 월에 따른 계절 저장 값
if(month>2 && month<6 ) {
season="봄";
}else if(month>5 && month<9) {
season="여름";
}else if(month>8 && month<12) {
season="가을";
}else {
season="겨울";
}
System.out.println("이달의 계절: "+season);
}else {
System.out.println("월을 잘못입력하였습니다.");
}
}
}
'Test > JAVA Test' 카테고리의 다른 글
1시간20분 전 시간 출력 (0) | 2023.05.14 |
---|---|
자판기 프로그램03 (0) | 2023.05.08 |
자판기 프로그램02 (0) | 2023.05.08 |
학생 6명에 대한 점수 구하기 (0) | 2023.05.08 |
나이에 맞게 금액 출력하세요. (0) | 2023.05.07 |