Computer Science, asked by sandhyasachan05, 4 months ago

the first day of 2010 was Friday write a program to input any day number within the month of January and print which day it was also check whether the day number entered is a valid date or not For example,
INPUT:
Enter day number: 20
OUTPUT: Wednesday
INPUT:
Enter day number:30
OUTPUT: Saturday
INPUT:
Enter day number:34
OUTPUT: Invalid day number​

Answers

Answered by ItzMeSam35
11

import java.util.*;

public class Jan

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Please Enter The Day Number");

int Day = sc.nextInt();

if ( Day == 3 || Day == 10 || Day == 17 || Day == 24 || Day == 31);

{

System.out.println("Sunday");

}

else if ( Day == 4 || Day == 12 || Day == 18 || Day == 25 );

{

System.out.println("Monday");

}

else if ( Day == 5 || Day == 12 || Day == 19 || Day == 26 );

{

System.out.println("Tuesday");

}

else if ( Day == 6 || Day == 13 || Day == 20 || Day == 27 );

{

System.out.println("Wednesday");

}

else if ( Day == 7 || Day == 14 || Day == 21 || Day == 28 );

{

System.out.println("Thursday");

}

else if ( Day == 1 || Day == 8 || Day == 15 || Day == 22 );

{

System.out.println("Friday");

}

else if ( Day == 2 || Day == 9 || Day == 16 || Day == 23 || Day == 30);

{

System.out.println("Saturday");

}

else

{

System.out.println("Invalid Day Number");

}

sc.close();

}

}

Similar questions