Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Created December 28, 2016 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokomokohitsuzi/145d03c3ea554d66fcd15a64c5c0c713 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/145d03c3ea554d66fcd15a64c5c0c713 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習7-6
import java.util.Scanner;
public class En07_06 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("季節を表示します。");
System.out.print("月を入力して下さい。:");
int m = stdIn.nextInt();
printSeason(m);
}
// switch文で表示を変更する。
static void printSeason(int m) {
switch (m) {
case 12:
case 1:
case 2:
System.out.print("冬");
break;
case 3:
case 4:
case 5:
System.out.print("春");
break;
case 6:
case 7:
case 8:
System.out.print("夏");
break;
case 9:
case 10:
case 11:
System.out.print("秋");
break;
default:
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment