Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Dates

love236
love236 


please see description in attached file thank you Attachments Tags
Clarifications

Answers

Answer for Assignment 8

mariobeka
mariobeka 



Below you'll find the java code for Birthday, Date and DateTest together with two .txt files containing the results. Attachments
Birthday.txt (1 K) Download Preview
leap year. It will be your birthday in 91 days. You are 21094 days old. What month, day, and year were you born? 4 1 1889 You were born on 1889/4/1, which was a Monday. It

TestDate.txt (1 K) Download Preview
23 It will be your birthday in 365 days. You are 8401 days old. What month, day, and year were you born? 12 3 1988 You were born on 1988/12/3, which was a Thursday. 1988 was

Birthday.java (2 K) Download Preview
Scanner input = new Scanner(System.in); System.out.print("What month, day, and year were you born? "); int month = input.nextInt(); int day = input.nextInt(); int year = input.nextInt(); TeacherDate date = new TeacherDate(year, month, day); TeacherDate today = new TeacherDate(); System.out.println("You were born on " + date.toString() + ", which was a

Date.java (2 K) Download Preview
toString() converts date to string and returns it public String toString() { return this.year + "/" + this.month + "/" + this.day; } // equals() compares to objects, and returns whether they are referring to // the same attributesreturns public boolean equals(Object o) { if (o instanceof Date) { Date

TeacherDate.java (4 K) Download Preview
= getDaysSinceEpoch(); for (int i = 0; i < daysSinceEpoch; i++) { this.nextDay(); } } // methods // Returns whether the given object is a TeacherDate that refers to the // same year/month/day as this TeacherDate. public boolean equals(Object o) { // a well-behaved equals method returns false

TestDate.java (2 K) Download Preview
age " + getAge(date, today)); } else if (date.isLeapYear()) { System.out.println(date.getYear() + " was a leap year."); } if (dayCounter(date, today) != 365) { System.out.println("It will be your birthday in " + daysUntilBirthday(date, today) + " days."); } System.out.println("You are " + dayCounter(date, today) + " days old."); } //

Screenshots
Purchase Answer