60 314
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #3503 in Java | JSP | JSF for Y mukundareddy

Question #3503
3. Write a program to print the days in a week if user enters 0….6 it should go in this manner if input=0 it should print Sunday and input ==1 It should print Monday, if input==2 it should give Tuesday and so on till Saturday.
Expert's answer
import java.util.Scanner;


public class DayOfWeekPrinter
{
public static void main(String[] args)
{
System.out.print("Enter the digital number from 0 to 6: ");
Scanner sc = new Scanner(System.in);
int dayNumber = sc.nextInt();
if (dayNumber == 0)
System.out.println("Sunday");
else if (dayNumber == 1)
System.out.println("Monday");
else if (dayNumber == 2)
System.out.println("Tuesday");
else if (dayNumber == 3)
System.out.println("Wednesday");
else if (dayNumber == 4)
System.out.println("Thursday");
else if (dayNumber == 5)
System.out.println("Friday");
else if (dayNumber == 6)
System.out.println("Saturday");
else
System.out.println("Wrong day number!");
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions