Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project, you\'ll begin to write a simple calendar application. In the fi

ID: 3869929 • Letter: I

Question

In this project, you'll begin to write a simple calendar application. In the first stage of the project, your goal is just to take a date (year, month, day of the month) and determine what day of the week it is (Monday, Tuesday. etc.) Your program, when run, should prompt the user for a year, month (numeric, 1-12), and day of the month, and then print out the day of the week that it is. An example run might look something like this: Input year: 2817 Input month:8 Input day of month: 28 8/28/2817 is a Monday For this, and later calendar projects, you can pretend that leap years don't exist. l'd suggest starting out by figuring how to translate the year/month/day input into a day of the week number from 0 to 6, and then translating that into the name of the day (0 . Sunday, 1 . Monday, etc.).

Explanation / Answer

package org.students;

import java.util.Calendar;

import java.util.Date;

import java.util.Scanner;

public class FindDayOfTheWeek {

public static void main(String args[]) {

int dd, mm, yy;

String weekDays[] = { "Sunday", "Monday", "Tuesday", "Wednesday",

"Thursday", "Friday", "Saturday" };

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

System.out.print("Input Year :");

yy = sc.nextInt();

System.out.print("Input month :");

mm = sc.nextInt();

System.out.print("Input day of the month :");

dd = sc.nextInt();

Date date = new Date(yy, mm, dd);

Calendar calendar = Calendar.getInstance();

calendar.setTime(date);

int n = calendar.get(Calendar.DAY_OF_WEEK);

System.out.print(mm + "/" + dd + "/" + yy + " is a " + weekDays[n - 1]);

}

}

___________________

Output:

Input Year :2017
Input month :8
Input day of the month :28
8/28/2017 is a Friday

__________________Thank YOu

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote