Write a class that will test dates and times inputted by the user and determine whether...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a class that will test dates and times inputted by the user and determine whether or not it is valid. This will focus on the usages of methods to organize code. Requirements: Functionality. (80pts) 。 No Syntax Errors. (80pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. • Set up the Project (10pts) ■First download the driver and include it in ■Do not alter the code found in the driver. • Use this to run your project your project. ■ Create a class and name it exactly DateAndTimeTester . Do not include the "main method" ■ All must apply for full credit. • Create the following methods in DateAndTimeTester ■ run: This method returns nothing and takes no parameters. This is called by the driver and should handle all of the input from the Scanner and dialog for the user. (5pts) ■isValid: returns true or false if a given String has the correct date and time. The String parameter should be formatted "MM/DD hh:mm" This method should call the methodsindo is ValidDate and is ValidTime to determine this. (5pts) Go to Settings to act is ValidDate: returns true or false if a given String has a correct date. The String parameter should be formatted "MM/DD" and should use the method getMonth and getDay to determine the date's validity. Also assume February only has 28 days. (10pts) ■is ValidTime: returns true or false if a given String has a correct time. The String parameter should be formatted "hh:mm" and should use the getHour and getMinute to determine the time's validity. Valid times are from 1 to 12. (10pts) getMonth: returns an integer value representing the month for a given String. The String parameter is expected to be formatted "MM/DD". (10pts) getDay: returns an integer value representing the day for a given String. The String parameter is expected to be formatted "MM/DD". (10pts) getHour: returns an integer value representing the hour for a given String. The String parameter is expected to be formatted "hh:mm". (10pts) ■ getMinute: returns an integer value representing the minute for a given String. The String parameter is expected to be formatted "hh:mm". (10pts) ■ HINT: Notice how each part of data is separated given its format. Notice how first the Date and the Time are separated, then notice how the Month and the Day are separated for a Date and notice how the Hour and Minute are separated for a Time. Noticing this will help extract the data Date and Time, then further extract (or get) the Month and Day from the Date and the Hour and Minute from the Time. • Coding Style. (10pts) 。 Code functionality organized within multiple methods other than the main method, and methods organized within multiple classes where appropriate. (5pts) o Readable Code. (5pts) Activate Go to Set ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (10pts) 。 Your name in the file. (5pts) 。 At least 5 meaningful comments in addition to your name. These must describe the function of the code it is near. (5pts) • For reference MM/DD hh:mm is Month/Date Hour : Minute respectively. For every part, it is valid to enter one or both digits, so "01/01 01:01” is valid and “1/1 1:01” is also valid. Example Dialog: Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 06/22 3:00 The date and time is valid! Would you like to exit? Type "quit" to exit or press [ENTER] to continue Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 9/31 12:00 The date and time is not valid Would you like to exit? Type "quit" to exit or press [ENTER] to continue Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 12/08 13:00 The date and time is not valid Would you like to exit? Type "quit" to exit or press [ENTER] to continue quit Good bye public class DateAndTimeDriver { public static void main(String[] args) { DateAndTimeTester dtTester = new DateAndTimeTester(); dtTester.run(); } } Write a class that will test dates and times inputted by the user and determine whether or not it is valid. This will focus on the usages of methods to organize code. Requirements: Functionality. (80pts) 。 No Syntax Errors. (80pts*) ■ *Code that cannot be compiled due to syntax errors is nonfunctional code and will receive no points for this entire section. • Set up the Project (10pts) ■First download the driver and include it in ■Do not alter the code found in the driver. • Use this to run your project your project. ■ Create a class and name it exactly DateAndTimeTester . Do not include the "main method" ■ All must apply for full credit. • Create the following methods in DateAndTimeTester ■ run: This method returns nothing and takes no parameters. This is called by the driver and should handle all of the input from the Scanner and dialog for the user. (5pts) ■isValid: returns true or false if a given String has the correct date and time. The String parameter should be formatted "MM/DD hh:mm" This method should call the methodsindo is ValidDate and is ValidTime to determine this. (5pts) Go to Settings to act is ValidDate: returns true or false if a given String has a correct date. The String parameter should be formatted "MM/DD" and should use the method getMonth and getDay to determine the date's validity. Also assume February only has 28 days. (10pts) ■is ValidTime: returns true or false if a given String has a correct time. The String parameter should be formatted "hh:mm" and should use the getHour and getMinute to determine the time's validity. Valid times are from 1 to 12. (10pts) getMonth: returns an integer value representing the month for a given String. The String parameter is expected to be formatted "MM/DD". (10pts) getDay: returns an integer value representing the day for a given String. The String parameter is expected to be formatted "MM/DD". (10pts) getHour: returns an integer value representing the hour for a given String. The String parameter is expected to be formatted "hh:mm". (10pts) ■ getMinute: returns an integer value representing the minute for a given String. The String parameter is expected to be formatted "hh:mm". (10pts) ■ HINT: Notice how each part of data is separated given its format. Notice how first the Date and the Time are separated, then notice how the Month and the Day are separated for a Date and notice how the Hour and Minute are separated for a Time. Noticing this will help extract the data Date and Time, then further extract (or get) the Month and Day from the Date and the Hour and Minute from the Time. • Coding Style. (10pts) 。 Code functionality organized within multiple methods other than the main method, and methods organized within multiple classes where appropriate. (5pts) o Readable Code. (5pts) Activate Go to Set ■ Meaningful identifiers for data and methods. ■ Proper indentation that clearly identifies statements within the body of a class, a method, a branching statement, a loop statement, etc. ■ All the above must apply for full credit. • Comments. (10pts) 。 Your name in the file. (5pts) 。 At least 5 meaningful comments in addition to your name. These must describe the function of the code it is near. (5pts) • For reference MM/DD hh:mm is Month/Date Hour : Minute respectively. For every part, it is valid to enter one or both digits, so "01/01 01:01” is valid and “1/1 1:01” is also valid. Example Dialog: Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 06/22 3:00 The date and time is valid! Would you like to exit? Type "quit" to exit or press [ENTER] to continue Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 9/31 12:00 The date and time is not valid Would you like to exit? Type "quit" to exit or press [ENTER] to continue Enter a date and time (MM/DD hh:mm) and I will determine if it is valid 12/08 13:00 The date and time is not valid Would you like to exit? Type "quit" to exit or press [ENTER] to continue quit Good bye public class DateAndTimeDriver { public static void main(String[] args) { DateAndTimeTester dtTester = new DateAndTimeTester(); dtTester.run(); } }
Expert Answer:
Answer rating: 100% (QA)
Answer Below is the implementation of the DateAndTimeTester class according to the given requirement... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
What are conjugate faults, and what stress information do they give?
-
State the equation of the regression line used to predict values of the criterion variable.
-
Using graphs displayed on a calculator, verify the identity in Exercise 43. Data from Exercises 43 Show that sin 2x/sin x = 2cos x.
-
Zachary and Carrie Sexton (the Buyers) were searching for a home in the Kings wood neighborhood of Atlanta, Georgia. The Buyers real estate agent learned that Russell and Linda Sewell (the Sellers)...
-
Messner Co. reported $145,000 of net income for 2010. The accountant, in preparing the statement of cash flows, noted several items occurring during 2010 that might affect cash flows from operating...
-
National health insurance refers to an insurance scheme that covers the entire population and is usually established by national registration. While available literature shows that utilization levels...
-
with the aid of practical examples, elucidate your understanding of the activities that normally take place in the strategic planning process of Government Departments
-
Start with 40% hexane, draw a McCabe-Thiele diagram for the separation of hexane and octane at T = 340 K. Include the main parts = 1) x = y line, 2) xy equilibrium curve (from Raoult's law --...
-
The balance in the unLaguna Realty Co. pays weekly salaries of $6,300 on Friday for a five-day week ending on that day. What is the adjustment at the end of the accounting period, assuming that the...
-
Identify common social norms that should be used in business in each selected country, as well as hand gestures and body language that should be avoided or that may cause unintended offense. the...
-
Scenario 1. Mike, a cash method, calendar year taxpayer, provides legal services to a wide range of clients. On December 20 of Year 1, Mike sent Developer a bill for $50,000 for services Mike...
-
What are some common vulnerabilities that can be found in an organization and what are some of the features of them? Search the peer-reviewed literature for examples of this if necessary. You may...
-
Given That: p : I will finish my project q : I will get good grades Write the (1) converse, (2) inverse, and (3) contrapositive of these statements. (1) (2) (3)
-
For the following exercises, write the first four terms of the sequence. a n = 2 n 2
-
A and B are independent events, and P(A) = 0.5 and P(B) = 0.8 .Find P(A and B).
-
A soft drink distributor is considering two new models of dispensing machines. Both the Harvard Company machine and the Fizzit machine can be adjusted to fill the cups to a certain mean...
-
Although most people are aware of minor dehydration symptoms such as dry skin and headaches, many are less knowledgeable about the causes of dehydration. According to a poll done for the Nutrition...
-
What is the primary business of Satyam Computer Services Ltd?
-
In January 2009, approximately how many employees did Satyam Computer Services employ?
-
What was the cash balance sheet amount and how much cash actually existed in the Satyams bank accounts?
Study smarter with the SolutionInn App