Implement a simple clock class

Assignment Help JAVA Programming
Reference no: EM131597962

TASK
Your task is to implement a simple clock class to keep track of the current time using 24-hour time representation. Your clock should allow the user to input the current time. Your clock should allow the user to advance the clock by an integer number of minutes up to 12 hours (720 minutes).Finally, your clock should be able to format the time it represents for screen output, that is, it should produce a string representation of the time in a four-digit format, with leading zeros where needed for hours and minutes, and the ':' character separating the hours and minutes (for example: 05:30, 15:04, 23:59).

INSTRUCTIONS

There are many ways to approach the architecture of the code. For this lab, use the following class design and responsibility allocation to code the logic. Use this logic only, do not deviate from these instructions:

1) A driver class (with main), called Lab9, should provide the following logic:
a) Prompt user for input for the current time hours and minutes. You may assume that these values are valid (i.e., you do not need to do any input validation for these values).
b) Call the Clock constructor with user input hours and minutes to create a new clock object.
c) Print the original user input time; use the clock's method to format the output before printing.
d) In a loop:
i) Prompt the user for a number of minutes to advance the clock, not to exceed 12 hours (720 minutes), or -1 to exit the program.
(1) Print an error message if the user entered a number greater than 720.
(2) Exit the program if the user entered -1.
(3) If the user provided an appropriate value for minutes, ask the Clock to advance the clock time, and then print the new time.
2) A Clock class should include:
a) Private integer data members for current time hours and minutes.
b) Public methods as follows:
i) a constructor that has two input parameters for user input hours and minutes, respectively, and sets the data members to these values
ii) a getCurrentTime method that has no input parameters, and returns the current time as a String, properly formatted
Hint: if your hour or minute count is less than 10, you need to insert a 0 (zero) character before the hour or minute to produce a 4-character time string
iii) an advanceTime method with a single input parameter for the number of minutes to advance the clock time, and no return value
Hint: if your new hour count exceeds 23, you need to calculate the correct hour value for the next day.
Hint: if your new minute count exceeds 59, you need to calculate the correct minute value

 

Reference no: EM131597962

Questions Cloud

What is the company debt-equity ratio : Fama’s Llamas has a weighted average cost of capital of 10.8 percent. What is the company's debt-equity ratio?
Write the definitions of the method copyqueue : Write the definitions of the method copyQueue and the copy constructor for the class QueueClass. Write a program to test these operations
What is the percentage return on your investment : What is the percentage return on your investment (ignore interest paid)?
How much could you lose in any given year : If an investment has an average return 10% with a standard deviation of 8%, how much could you lose in any given year?
Implement a simple clock class : Implement a simple clock class to keep track of the current time using 24-hour time representation. Your clock should allow the user to input current time
Define significance of strategic role of human resources : This paper will summarize the findings of the first two power point presentations and incorporate them into a paper that will add an action plan of major tasks.
Which investment type has had the greatest return : Which investment type has had the greatest return since 1925? Compare and contrast the two investments. Specifically, discuss the standard deviation.
Was communication approach taken effective why or why not : Was the communication approach taken effective? Why or Why Not? If the tables were turned, how would you have approached the communication of same information?
What is the frictional unemployment rate : Each? month, 35 new people? (not including the 23lacking required? skills) continue to become? unemployed, but each monthly group.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd