(The Time Class) Design a class named Time. The class contains:
The data fields hour, minute and second that represent a time.
A no-arg constructor that creates a Time object for the current time. (The values of the data fields will represent the current time)
A constructor that constructs a Time object with a specified elapsed time since midnight, January 1 1970 in milliseconds.( The values of the data fields will represent this time)
A constructor that constructs a Time object with the specified hour, minute and second.
Three getter methods for the data fields hour, minute and second respectively
A method name setTime(long elapseTime) that sets a new time for the object using the elapsed time. For example if the elapsed time is 555550000 milliseconds, the hour is 10, the minutes is 10 and the second is 10
Draw the UML diagram for the class and then implement the class. Write a test program that creates two Time objects (using new Time() and new Time(555550000)) and displays their hour,minuts and second in the format hour:minute:second
(Displaying the prime factors) Write a program that promtps the user to enter a positive integer and displays all its smallest factors in decreasing order. For example, if the integer is 120, the smallest factors are displayed as 5,3,2,2. Use the StackOfIntegers class to StackOfIntegers the factors (e.g 2,2,2,3,5) and retrieve and display them in reverse order.
(The Queue Class) Section 10.6 gives a class for Stack. Design a class named Queue for storing integers. Like a stack, a queue holds elements In a stack, elements are retrieved in a last-in-first-out fashion. In a queue, the elements are retrieved in a first-in-first-out fashion. The
An int data field named elements that store int values in the queue
A data field named size that stores the number of elements in the queue
A constructor that creates a Queue object with the default capacity 8
The method enqueue(int v) that adds v into the queue
This assignment has been answered 2 times in private sessions.
© 2021 Codify Tutor. All rights reserved