Question: Lab Exercise 04.1 The Clock class PLEASE USE JAVA This exercise will ask you to design a Clock class which will display the time in

Lab Exercise 04.1

The Clock class

PLEASE USE JAVA

This exercise will ask you to design a Clock class which will display the time in digital format (ex: 10:45:13 pm). You will design and implement the class to do calculations in clock time. The Clock will contain, at a minimum, the following attributes:

The current time hours (0..12) - integer

The current time minutes (0..59 - integer

The current time seconds (0..59) integer

The day-cycle of the current time (a.m. or p.m.)

A printable version of the current time Ex: 10:02:41 a.m. string

The Clock will contain, at a minimum, the following methods:

A constructor that accepts 3 arguments, hours, minutes and seconds and sets the day-cycle to a.m.

A constructor that accepts 3 arguments, hours, minutes and seconds and sets the day-cycle to p.m.

A constructor that accepts no arguments and sets the current time to midnight.

A method that accepts as an argument, the name of another object of class-clock and returns the hours, minutes and seconds between the current time and the time in the argument object.

A method that accepts 3 arguments, hours, minutes, seconds and uses these values to set the current time.

Testing: You will test this class by creating several Clock objects and exercising the various methods. All input must be validated.

Lab Exercise 04.2

Quadratic Equation Solver

PLEASE USE JAVA

Design a class called QuadraticEquation which will contain a quadratic equation in standard form, . Actually it will contain only the coefficients a, b and c. The class contains:

Private data fields a, b and c that represent the three coefficients.

A constructor method with arguments for a, b and c.

Three get methods for a, b and c. Dont forget to validate the input.

A method named getDiscriminant() that returns the discriminant which is ).

Two methods named getRoot1() and getRoot2() which return the two roots of the equation.

Root1 = and root2 =

These methods are useful only if the discriminant is not negative.

If the discriminant is

positive, there are two real roots.

zero, the two roots are identical.

negative, display No real roots.

Testing: You will test with any combination of valid values for a, b and c that you wish. Additionally you will test with non-numeric values and values that result in both identical roots and no roots. Remember that EVERY quadratic equation with real roots has TWO of them, even when they have identical values. In the case of identical values, you must display both roots.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!