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

1-Edit the following class Date in to jGraspe Save it as E:\\Date.java then comp

ID: 3681762 • Letter: 1

Question

1-Edit the following class Date in to jGraspe Save it as E:Date.java then compile that file in jGraspe then you will see in your drive a file: E:Date.class (You can use eclipse or the tutorialspoint.com online compiler too) public class Date { protected int year; protected int month; protected int day; public static final int MINYEAR = 1583; // Constructor public Date(int newMonth, int newDay, int newYear) { month = newMonth; day = newDay; year = newYear; } // Observers public int getYear() { return year; } public int getMonth() { return month; } public int getDay() { return day; } public int lilian() { final int subDays = 578100; // number of calculated days from 1/1/0 to 10/14/1582 int numDays = 0; // Add days in years. numDays = year * 365; // Add days in the months. if (month <= 2) numDays = numDays + (month - 1) * 31; else numDays = numDays + ((month - 1) * 31) - ((4 * (month-1) + 27) / 10); // Add days in the days. numDays = numDays + day; // Take care of leap years. numDays = numDays + (year / 4) - (year / 100) + (year / 400); // Handle special case of leap year but not yet leap day. if (month < 3) { if ((year % 4) == 0) numDays = numDays - 1; if ((year % 100) == 0) numDays = numDays + 1; if ((year % 400) == 0) numDays = numDays - 1; } // Subtract extra days up to 10/14/1582. numDays = numDays - subDays; return numDays; } } 2-Edit the following code then save it as E:DaysBetrween.java Compile then fix errors, if any! Then run the program then have screen shot. import java.util.Scanner; public class DaysBetween { public static void main(String[] args) { Scanner conIn = new Scanner(System.in); int day, month, year; System.out.println("Enter two 'modern' dates: month day year"); System.out.println("example: January 12, 1954, would be: 1 12 1954"); System.out.println(); System.out.println("Modern dates occur after " + Date.MINYEAR + "."); System.out.println(); System.out.println("Enter the first date:"); month = conIn.nextInt(); day = conIn.nextInt(); year = conIn.nextInt(); Date date1 = new Date(month, day, year); System.out.println("Enter the second date:"); month = conIn.nextInt(); day = conIn.nextInt(); year = conIn.nextInt(); Date date2 = new Date(month, day, year); if ((date1.getYear()<=Date.MINYEAR) || (date2.getYear()<=Date.MINYEAR)) System.out.println("You entered a 'pre-modern' date."); else { System.out.println("The number of days between"); System.out.println("days for date1: "+ date1.lilian()); System.out.println("days for date2: "+ date2.lilian()); int days=date2.lilian() - date1.lilian(); System.out.println("days in between: "+days); } } }

Explanation / Answer

You have saved second file with wrong name(DaysBetrween.java) it should be DaysBetween.java

no error in code

first make a new empty java project with any name.

then add first java file

Date.java

public class Date {
protected int year;
protected int month;
protected int day;
public static final int MINYEAR = 1583;
// Constructor
public Date(int newMonth, int newDay, int newYear) {
month = newMonth;
day = newDay;
year = newYear; }
// Observers
public int getYear() {
return year; }
public int getMonth() {
return month; }
public int getDay() {
return day; }
public int lilian() {
final int subDays = 578100;
// number of calculated days from 1/1/0 to 10/14/1582
int numDays = 0;
// Add days in years.
numDays = year * 365;
// Add days in the months.
if (month <= 2)
numDays = numDays + (month - 1) * 31;
else
numDays = numDays + ((month - 1) * 31) - ((4 * (month-1) + 27) / 10);
// Add days in the days.
numDays = numDays + day;
// Take care of leap years.
numDays = numDays + (year / 4) - (year / 100) + (year / 400);
// Handle special case of leap year but not yet leap day.
if (month < 3) {
if ((year % 4) == 0)
numDays = numDays - 1;
if ((year % 100) == 0)
numDays = numDays + 1;
if ((year % 400) == 0)
numDays = numDays - 1; }
// Subtract extra days up to 10/14/1582.
numDays = numDays - subDays;
return numDays;
} }

then add second java file DaysBetween.java

import java.util.Scanner;
public class DaysBetween {
public static void main(String[] args) {
Scanner conIn = new Scanner(System.in);
int day, month, year;
System.out.println("Enter two 'modern' dates: month day year");
System.out.println("example: January 12, 1954, would be: 1 12 1954");
System.out.println();
System.out.println("Modern dates occur after " + Date.MINYEAR + ".");
System.out.println();
System.out.println("Enter the first date:");
month = conIn.nextInt();
day = conIn.nextInt();
year = conIn.nextInt();
Date date1 = new Date(month, day, year);
System.out.println("Enter the second date:");
month = conIn.nextInt();
day = conIn.nextInt();
year = conIn.nextInt();
Date date2 = new Date(month, day, year);
if ((date1.getYear()<=Date.MINYEAR) || (date2.getYear()<=Date.MINYEAR))
System.out.println("You entered a 'pre-modern' date.");
else {
System.out.println("The number of days between");
System.out.println("days for date1: "+ date1.lilian());
System.out.println("days for date2: "+ date2.lilian());
int days=date2.lilian() - date1.lilian();
System.out.println("days in between: "+days);
} } }

save all the code and run this file

Output :

Enter two 'modern' dates: month day year
example: January 12, 1954, would be: 1 12 1954

Modern dates occur after 1583.

Enter the first date:
2
26
2016
Enter the second date:
3
26
2016
The number of days between
days for date1: 158285
days for date2: 158314
days in between: 29