标签:color class cas main ase scan sample sys 语句
//switch statement import java.util.Scanner; public class Sample { public static void main(String[] args) { int num; Scanner ip = new Scanner(System.in); System.out.print("Enter number between 1 to 4: "); num = ip.nextInt(); switch (num) { case 1: System.out.println("Entered number is one"); break; case 2: System.out.println("Entered number is two"); break; case 3: System.out.println("Entered number is three"); break; case 4: System.out.println("Entered number is four"); break; default: System.out.println("invalid input"); } ip.close(); } } OUTPUT: Enter number between 1 to 4: 3 Entered number is three
标签:color class cas main ase scan sample sys 语句
原文地址:https://www.cnblogs.com/sea-stream/p/12095992.html