
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
The driver :
public class DateAndTimeDriver { public static void main(String[] args) { // TODO Auto-generated method stub DateAndTimeTester dtTester = new DateAndTimeTester(); dtTester.run(); } }
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.
- 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 methods isValidDate and isValidTime to determine this.
- isValidDate: 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 times are from 1 to 12.
- getMonth: returns an integer value representing the month for a given String. The String parameter is expected to be formatted “MM/DD”.
- getDay: returns an integer value representing the day for a given String. The String parameter is expected to be formatted “MM/DD”.
- getHour: returns an integer value representing the hour for a given String. The String parameter is expected to be formatted “hh:mm”.
- getMinute: returns an integer value representing the minute for a given String. The String parameter is expected to be formatted “hh:mm”.
- For reference MM/DD hh:mm is Month / Date Hour : Minute respectively
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

Trending nowThis is a popular solution!
Step by stepSolved in 6 steps with 1 images

- Task 5 Create an Employee Class that will have Two instance variable: name and workingPeriod A class method named employeeByJoiningYear(): • To create an Employee object by joining year for calculating the working period o it will have two Parameter name and year • A static method experienceCheck() to check if an Employee is experienced or not o It will take working period and gender as parameter o If an employee's working period is less than 3, he or she is not experienced [You are not allowed to change the code below] # Write your code here employee1 = Employee('Dororo', 3) employee2 = Employee.employeeByJoiningYear('Harry', 2016) 5 print(employee1.workingPeriod) print(employee2.workingPeriod) print(employee1.name) Оutput 3 Dororo Harry He is not experienced She is experienced print(employee2.name) print(Employee.experienceCheck(2, "male")) print(Employee.experienceCheck(3, "female"))arrow_forwardThese are all true or false questionsarrow_forwardDraw Design Layout References Mailings Review View Help Create a Java program and name your file: FIRSTNAME. java (for example, lohn.java). Work on the following: Create three interfaces with the names "InterfaceOne," "IrnterfaceTwo," and "Interfacelhree" In the first interface, declare a method (signature only) with a name "updateGear()." In the second interface, dedare a method (signature only) with a name "accelerate()." In the third interface, dedare a method (signature only) with a name "pusherake()." Create two classes Car and Truck that implement these three interfaces at one time. Define a new method "currentSpeed()" in both the classes to find the current speed after the brake. • Define all the three methods inside each class. The data to these methods will be provided during the object creation. Invoke the two objects with a name c1 of class Car and t1 of class Truck. • After creating the objects, call all the three methods defined above in both the classes. Pass any of the…arrow_forward
- Look through the method header below, then, as an example, write a call to the method. an internal void ShowValue()arrow_forwardIn java language Class Design – Date V0.0 & V1.0 Create a new project for this lab and create a new class inside called Date. If you created a Date class last week, you may use it as a base. What does it mean to be a Date? What data items (called “state”) do you need to keep track of? Alternatively, what does a date have? (“has a” == composition) What can a Date do? What are the actions and verbs that can be applied to a date? Come up with one or two. These become the class’s methods. Try adding 3 data items to your Date to manage the month, day and year. Should these be local variables? Class-level (or instance) variables? Now let’s build a method to set the date This function should take 3 integers as input and assign these to your instance variables declared in the previous step. public void setDate(int m, int d, int y) { And, let’s build a method to report the date This function takes no input and uses the console to output the Date in the format…arrow_forwardCreate a class called SquareTester that will create a Square object. Print out the toString method with the object as your receiver. Print out the perimeter using the getArea method and the object as your receiver. public class SquareTester { public static void main(String{}args) { //create your Square object with any value as your argument //print the toString method //print the area of the square on a new line -ex: “The area is: 64” } }arrow_forward
- Please add to the Game code below (TODO LISTED): /*TODO add no argument constructor constructor*//*TODO add three argument constructor*//*TODO create an attack method that returns a random value from 1 to weapon's strength and deducts 1 from durability*//*TODO in the attack method if durability is 0 return 0*//*TODO create a toString override*/ import java.util.Random; //Game driver//Notice it's the only class declared as public.public class GameBattleDriver{public static void main(String [] args){Character hero = new Character("Sparhawk", 40, 10);//System.out.println(Character.numChars);Character badguy = new Character("Gwerg", 100, 3);//System.out.println(Character.numChars);Character hero2 = new Character("Sparhawk", 40, 10);//System.out.println(Character.numChars);//BattleArena b1 = new BattleArena(hero, badguy);//b1.fight();BattleArena.fight(hero,…arrow_forwardIn Java Write a Fraction class that implements these methods:• add ─ This method receives a Fraction parameter and adds the parameter fraction to thecalling object fraction.• multiply ─ This method receives a Fraction parameter and multiplies the parameterfraction by the calling object fraction.• print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)• printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)• Separate accessor methods for each instance variable (numerator , denominator ) in theFraction classProvide a driver class (FractionDemo) that demonstrates this Fraction class. The driver class shouldcontain this main method : public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print(); System.out.println("Enter numerator; then denominator."); d = new…arrow_forwardImage 1 is my code, and image 2 is how to calculate the score. i need to write 2 methods (Inalready wrote the method 3) Method 3: A method to collect the required patient information (age, zip code, insurance information, pain level, and temperature) and compute the priority score takes one Scanner parameter returns the computed score Method 4: A method to calculate the priority score of the patient (this method should be called in the method 3) takes five parameters, once for each patient feature returns the computed scorearrow_forward
- A method to find a set of value of instance variable Choose one Accessor method Reference method Getter method Mutator methodarrow_forwardWrite the following two methods: computeDiameter: This method accepts the radius (r) of a circle, and returns its diameter (2*r; radius = 7.5). Declare all variables used here & initialize radius: Show method call: Write method code here: displayData: This method accepts two arguments: radius & diameter. The output should have appropriate messages on the screen. Show method call: Write method code here:arrow_forwardA method CAN Not be invoked using a variable that is initialized to null. True Falsearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





