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
-
The following data represents lawn mower sales at Jennifer's hardware store Using a Moving Average of 4 periods, what would the forecast for Period 9 be? Using an Exponential Smoothing method with a...
-
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?
-
Draw the pH-activity profile for an enzyme with one catalytic group at the active site. The catalytic group is a general-acid catalyst with a pKa of 5.6.
-
A hot sauce company rates its sauce on a scale of spiciness of 1 to 20. A sample of 50 bottles of hot sauce is taste-tested by a random sample of people from the population. The taste test resulted...
-
Investment professionals use a variety of financial ratios to evaluate a companys financial risk. Two popular financial risk ratios include: 1. Long-term debt-to-equity ratio 2. Interest coverage...
-
Warner Inc. sells a high-speed retrieval system for mining information. It provides the following information for the year. Overhead is applied on the basis of direct labor hours. (a) Compute the...
-
Hello, can someone provide a step by step process and explanation thank you 22 42 cose de= So+sine (A) -2(2-1) (D) 2(2-1) (B) -22 (C) 22 (E) 2(2+1)
-
Jane Company purchased merchandise . The following information is available: Terms: 15/10 n /60 Original purchase amount: $ 7,000 Return amount: $ 1,000 (2 days after purchase ) Payment of cash: Paid...
-
Based on your article about the pot, provide an example of the following: a. Startup Costs b. Fixed Costs c. Variable Costs Required: Read the article about the self-watering system pot and answer...
-
Advertisers can mislead through exaggeration by making claims unsupported by evidence. Puffery is the supposedly harmless use of superlatives and subjective praise in advertisements. Give an example...
-
Suppose the TLK Corporation issued bonds a few years ago with a par value of $1,000 and an annual interest payment of $130. If their current yield is 10 percent, their current market (or resale)...
-
Provide an assessment of the likely effectiveness of the Federal Government's policies and actions in assisting companies withstand the negative impact of the effective shutdown of many economic...
-
a ) Sutera Business Sdn Bhd has recorded sales of 2 5 0 , 0 0 0 units at RM 1 2 in the financial year 2 0 2 2 . The operating costs of Sutera Business Sdn Bhd are as follows: Operating Variable cost...
-
What was the price/earnings ratio of the ten largest companies - by market capitalisation - on the ASX at the end of January 2020 and at Friday 20 March 2020? Do you think this ratio is relevant to...
-
A qualified disclaimer is a valuable estate planning tool because a. It qualifies the assets for the alternative valuation date b. It allows the person making the disclaimer to determine the...
-
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...
-
If the price of zucchini increases, causing the demand for yellow squash to rise, what do we call the relationship between zucchini and yellow squash?
-
The price elasticity of demand is defined as the percentage change in _________ divided by the percentage change in _________.
-
The price elasticity of demand measures the responsiveness of quantity _________ to a change in price.
Study smarter with the SolutionInn App