Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java class named MyTime that contains three data members which are hour, minute, and second. Note that the valid values for hour, minute

image text in transcribed

Write a Java class named MyTime that contains three data members which are hour, minute, and second. Note that the valid values for hour, minute and second are: 0-23, 0-59, 0-59 respectively. The class should implement the following constructors/methods: A default constructor that sets all the data members to zero. . A constructor with arguments that sets the time to given hour, minute, and second. . get and set methods . incrementSecond(), incrementMinute(), and incrementHour(): increment time by one second, one minute, and one hour respectively. . toString():represents a myTime object in universal time format (HH:MM:SS). toStandard Time(): converts the time to standard time format (H:MM:SS AM/PM) Write a test program that creates a myTime object with hour, minute, and second given as input from the user. Print the object myTime in both universal and standard format. Increment the time by one second and print the new time in the universal format. Sample input/output Enter the time starting with hour, minute and second: 78 59 The time in universal format is: 07:08:59 The time in standard format is: 07:08:59 AM The new time after one second is: 07:09:00 Enter the time starting with hour, minute and second: 23 59 59 The time in universal format is: 23:59:59 The time in standard format is: 11:59:59 PM After one second, the time is: 00:00:00

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions