Input week number and print week day
Sample Output
Input week number and print week day. Enter week number(1 - 7): 1 Week number 1 for Saturday.
Java-Source Code
//package ifelsejava;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int number;
Scanner input = new Scanner(System.in);
System.out.println("Input week number and print week day.\n");
System.out.print("Enter week number(1 - 7): ");
number = input.nextInt();
if (number == 1) {
System.out.println("Week number "+ number + " for Saturday.");
} else if(number == 2){
System.out.println("Week number "+ number + " for Sunday.");
} else if(number == 3){
System.out.println("Week number "+ number + " for Monday.");
} else if(number == 4){
System.out.println("Week number "+ number + " for Tuesday.");
} else if(number == 5){
System.out.println("Week number "+ number + " for Wednesday.");
} else if(number == 6){
System.out.println("Week number "+ number + " for Thursday.");
} else if(number == 7){
System.out.println("Week number "+ number + " for Friday.");
} else{
System.out.println("Invalid week number!");
}
}
}
Sample Output
Input week number and print week day. Enter week number(1 - 7): 5 Week number 5 for Wednesday.
No comments:
Post a Comment