Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program using dr.java. I added a picture of the driver, my code so far and a picture of what the code is suppose to do.

Program using dr.java. I added a picture of the driver, my code so far and a picture of what the code is suppose to do. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Lab 12 Date and Time Methods Objective: 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. First download the driver and put it in your project . DO NOT ALTER THE DRIVER! . Use this to run your project Write a class file called DateAndTimeTester . This DOES NOT have a main method . Create the following methods 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 isalid: 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 methods is ValidDate and is ValidTime to determine this sValidDate: 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. isvalidTime: 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 o getMonth: returns an integer value representing the month for a given String. The String parameter is o getDay: returns an integer value representing the day for a given String. The String parameter is o getHour: returns an integer value representing the hour for a given String. The String parameter is o getMinute: returns an integer value representing the minute for a given String. The String parameter is times are from 1 to 12. expected to be formatted "MM/DD" expected to be formatted "MM/DD expected to be formatted "hh:mm" expected to be formatted "hh:mm" . For reference MM/DD hh:mm is Month / Date Hour : Minute respectively save 11 E 1 Close % Cut | Copy Paste Unc Written by Anthony Chandler public class DateAndTimeDriver ( public static void main(Stringt i args)f // TODO Auto-generated method stub DateAndTimeTe ster dtTe ster new DateAndTimeTester(); dtTester. run() 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 ed Ldngdage Level Help Isave E. Close %Cut D Copy Paste Undo eRedo Find Comp Written by Anthony Chandler import java.util.Scanner: public class DateTimeMethod ( private int month: private int day: private int hour private int ninute; //Entering the month day hour and minute public void run) t Scanner keyboard new Scanner (System. in): System.out.printin("Enter a date and time MM/DD hh:ma and i vill determine if it is valid"): int slash month. indexof(": String m month. substring (o,slash) int month Integer.parseInt(nonth)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions