Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program; 1. A class named watch meets the following requirements: The class has three variables: hours (type int), minutes (type int), and

Write a java program;

1. A class named watch meets the following requirements: The class has three variables: hours (type int), minutes (type int), and seconds (type int). The class has a parameterized constructor that takes three parameters. The constructor constructs a Clock with the specified time values.

\A method named updateTime with one argument (totalSecs). It increases the time of the watch by passing the total number of seconds, however, all parameters should be updated after rounding as follows hours = totalSecs / 3600; minutes = (totalSecs % 3600) / 60; seconds = totalSecs % 60; you can use Math.round(value) for rounding

2. A test class that contains the main method w program that creates a Clock is created with hour 10, minutes 20, and seconds 30 and then invokes the updateTime method once by passing 7000 sec as a parameter.

Write the code for the two classes considering the above requirements

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

Step: 3

blur-text-image

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

5. Have you stressed the topics relevance to your audience?

Answered: 1 week ago