DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Write a class NameOfTheDay with a main method. The method receives one command line argument. The method should convert the argument String to int

Write a class NameOfTheDay with a main method. The method receives one command line argument. The method should convert the argument String to int.

The program should print the name of the weekday based on the value of the day (1-7), using the switch statement.

For example:

Cmd Args : 3
Wednesday 

Similarly, if the input is given as 10 then the output should be Number 10 is not in the range 1 to 7.

For example:

Cmd Args : 10
Number 10 is not in the range 1 to 7

Ensure that the name of the day starts with a capital letter.

Solution:

package q10874;

public class NameOfTheDay{
	public static void main(String[] args) {
		int value = Integer.parseInt(args[0]);
		
		switch(value){
			case 1:
				System.out.println("Monday");
				break;
			case 2:
				System.out.println("Tuesday");
				break;
			case 3:
				System.out.println("Wednesday");
				break;
			case 4:
				System.out.println("Thursday");
				break;
			case 5:
				System.out.println("Friday");
				break;
			case 6:
				System.out.println("Saturday");
			    break;
			case 7:
				System.out.println("Sunday");
				break;
			default:
			    System.out.println("Number "+value+" is not in the range 1 to 7");
			
		}
	}
}

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)

Leave a Comment