Java Tutorial 12 --- "Switch Case Statements"
DOC ---
CODE ---
package com.company;
import java.util.Scanner;
public class Tut12 {
public static void main(String[] args) {
// Switch Case Statements
System.out.println("Please enter your Number");
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
switch (number) {
case 18 -> System.out.println("You have won nothing but you have to Pay Double");
case 7 -> System.out.println("You have won the Double Prize");
case 777 -> System.out.println("You have won the MEGA Prize");
case 13 -> System.out.println("You cant win any prizes for one year");
}
if (number>=60){
System.out.println("Congratulations! You have won the Platinum Prize ");
}
else if (number>=50){
System.out.println("Congratulations! You have won the Golden Prize ");
}
else if (number>=40){
System.out.println("Congratulations! You have won the Silver Prize ");
}
else if (number>=30){
System.out.println("Congratulations! You have won the Bronze Prize ");
}
else{
System.out.println("Sorry! You have won nothing ");
}
}
}
Comments
Post a Comment