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.
1
Expert's answer
2011-08-16T11:56:09-0400
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!"); } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment