Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Lab 01 CS 240, Lab 01 Objectives: Review of Java concepts Exposure to code from textbook Practice modifying existing code Experience with Scanner class Improve your programming and documentation style Handling input errors (not use Exception Handling yet, though)   You will use Date.java and DaysBetween.java files from the book files folders. Note that these two classes are discussed in Chapter 1 in the textbook. 1. Create Lab01 Folder. 2. Copy ch01 folder from book files to new folder. 3. Edit/create files in the ch01 folder as directed below. First, compile and run DaysBetween.java to familiarize yourself with its functionality.  How many days have you been alive? Next, make the following three modifications: 1. Modfiy the Date class so its toString method returns a string of the form "month number, number". For example, May 13, 1984, and then modify DaysBetween so that after a date is input, it is output in this form. 2. Modify the DaysBetween application so that it uses the Scanner class's hasNextInt method to check that the next input value is an integer before reading it. If it is not, the program should display the message "Illegal input was entered" and exit. Note that you can use Java's return statement to exit the program. Consider how you may do this more efficiently, by minimizing repetition of code. 3. The Date class does not check for the validity of dates. Add a public instance method, called valid, to the Date class. This method should return true if the date represented by the object is a valid date, and false otherwise. Valid dates are "real" dates that occur on or after January 1, 1583. Don't forget about leap years (Ayear is a leap year if either (i) it is divisible by 4 but not by 100 or (ii) it is divisible by 400). After creating and testing the valid method, use it to check dates from within the DaysBetween program. If an invalid date is entered, display the message, "That is not a valid date" and exit.