Computer Science, asked by abhishekyadav0223, 17 hours ago

1. WAP to accept a number from the user (1-7) and print the corresponding day (eg:1 -Sunday) ​

Answers

Answered by ItzMeSam35
1

import java.util.Scanner;

public class Days

{

public static void main (String args[])

{

Scanner sc=new Scanner (System.in);

System.out.print("Please enter day number: ");

int dayN = sc.nextInt();

if (dayN == 1)

{

System.out.println("Monday");

}

else if (dayN == 2)

{

System.out.println("Tuesday");

}

else if (dayN == 3)

{

System.out.println("Wednesday");

}

else if (dayN == 4)

{

System.out.println("Thursday");

}

else if (dayN == 5)

{

System.out.println("Friday");

}

else if (dayN == 6)

{

System.out.println("Saturday");

}

else if (dayN == 7)

{

System.out.println("Sunday");

}

else

{

System.out.print("Invalid Day Number Entered");

}

sc.close();

}

}

Similar questions
Math, 8 months ago