Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago