Java Programming Task 1 With Solution
Task 1 : Design a class named StopWatch. The class contains: Private data fields are startTime and endTime with getter methods. A no-arg constructor that initializes startTime with the current time. A method named start() that resets the startTime to the current time. A method named stop() that sets the endTime to the current time. A method named getElapsedTime() that returns the elapsed time for the stopwatch in milliseconds. Write a test program and create a stopwatch and call all methods. Solution : The task is explanatory itself, if you focus however here's an explanation for you: First of all, declare two private data fields 'startTime' & 'endTime' as said in the task, as we know the time can set in seconds means values in points, therefore, we have to use data type float. Then, we have asked to create a no argument constructor which will be used to initialize the current time. Then we have to create methods of s...