Question: Can someone help me? I am taking computer science I and need help with example 8-2 and 8-8 in the DS Malik 5th edition programming

Can someone help me? I am taking computer science I and need help with example 8-2 and 8-8 in the DS Malik 5th edition programming book. I've done the code for 8-2 but it's not working. Please fix it for me. Thanks!

import java.util.*;

public class TestProgClock {

static Scanner console = new Scanner(System.in); public static void main(String[] args) { Clock myClock = new Clock(5, 4, 30); Clock yourClock = new Clock(); int hours; int minutes; int seconds; System.out.print("Line 6: myClock: "); myClock.printTime(); System.out.println(); System.out.print("Line 9: yourClock: "); yourClock.printTime(); System.out.println(); yourClock.setTime(5, 45, 16); System.out.print("Line 13: After setting " + "the time, yourClock: "); yourClock.printTime(); System.out.println(); if (myClock.equals(yourClock)) System.out.println("Line 17: Both the " + "time are equal."); else System.out.println("Line 19: The two " + "time are not" + "equal."); System.out.print("Line 20: Enter hours, " + "minutes, and seconds: "); hours = console.nextInt(); minutes = console.nextInt(); seconds = console.nextInt(); System.out.println(); myClock.setTime(hours, minutes, seconds); System.out.print("Line 26: New time of " + "myClock: "); myClock.printTime(); System.out.println(); myClock.incrementSeconds(); System.out.print("Line 30: After" + "incrementing the time by " + "one second, myClock: "); myClock.printTime(); System.println(); yourClock.makeCopy(myClock); System.out.print("Line 34: After copying" + "myClock into yourClock, " + " yourClock: "); yourClock.printTime(); system.out.println(); } }

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!