1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vivado [14]
3 years ago
15

Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int

for the minutes, and an int for the seconds. The class should include a threeargument constructor and get and set methods for each instance variable. Override the method toString which should return the Clock information in the same format as the input file (See below). Read the information about a Clock from a file that will be given to you on Blackboard, parse out the three pieces of information for the Clock using a StringTokenizer, instantiate the Clock and store the Clock object in two different arrays (one of these arrays will be sorted in a later step). Once the file has been read and the arrays have been filled, sort one of the arrays by hours using Selection Sort. Display the contents of the arrays in a GUI that has a GridLayout with one row and two columns. The left column should display the Clocks in the order read from the file, and the right column should display the Clocks in sorted order.
Computers and Technology
1 answer:
Anvisha [2.4K]3 years ago
3 0

Answer:

public class Clock

{

private int hr; //store hours

private int min;  //store minutes

private int sec; //store seconds

public Clock ()

{

 setTime (0, 0, 0);

}

public Clock (int hours, int minutes, int seconds)

{

 setTime (hours, minutes, seconds);

}

public void setTime (int hours, int minutes, int seconds)

{

 if (0 <= hours && hours < 24)

      hr = hours;

 else

      hr = 0;

 

 if (0 <= minutes && minutes < 60)

      min = minutes;

 else

      min = 0;

 

 if (0 <= seconds && seconds < 60)

      sec = seconds;

 else

      sec = 0;

}

 

 //Method to return the hours

public int getHours ( )

{

 return hr;

}

 //Method to return the minutes

public int getMinutes ( )

{

 return min;

}

 //Method to return the seconds

public int getSeconds ( )

{

 return sec;

}

public void printTime ( )

{

 if (hr < 10)

      System.out.print ("0");

 System.out.print (hr + ":");

 if (min < 10)

      System.out.print ("0");

 System.out.print (min + ":");

 if (sec < 10)

      System.out.print ("0");

 System.out.print (sec);

}

 

 //The time is incremented by one second

 //If the before-increment time is 23:59:59, the time

 //is reset to 00:00:00

public void incrementSeconds ( )

{

 sec++;

 

 if (sec > 59)

 {

  sec = 0;

  incrementMinutes ( );  //increment minutes

 }

}

 ///The time is incremented by one minute

 //If the before-increment time is 23:59:53, the time

 //is reset to 00:00:53

public void incrementMinutes ( )

{

 min++;

 

if (min > 59)

 {

  min = 0;

  incrementHours ( );  //increment hours

 }

}

public void incrementHours ( )

{

 hr++;

 

 if (hr > 23)

     hr = 0;

}

public boolean equals (Clock otherClock)

{

 return (hr == otherClock.hr

  && min == otherClock.min

   && sec == otherClock.sec);

}

}

You might be interested in
When a cardholder successfully contests a charge, the acquiring bank must retrieve the money it placed in the merchant account i
lions [1.4K]

Answer:

Charge back.

Explanation:

A chargeback is a charge that is returned to a payment card after a customer successfully disputes an item on their account transactions report. Simply put, it is the reversal of a credit card payment that comes directly from the bank.

Most commonly the payer is a consumer.

A chargeback may occur on bank accounts or credit cards. They can be granted to a cardholder for a variety of reasons. A chargeback can be considered a refund since it returns specified funds taken from an account through a prior purchase. Chargebacks are focused on charges that have been fully processed and settled. Chargebacks can often take several days for full settlement as they must be reversed through an electronic process involving multiple entities.

The chargeback is ordered by the bank that issued the consumer's payment card.

6 0
3 years ago
The Appliance Warehouse case study is designed to practice systems analysis and design skills using a life-like scenario. Applia
nikdorinn [45]

Answer:

A service department that I would create for a product from Appliance Warehouse is:

The washing machines service department.

Explanation:

Appliance Warehouse is one of the most important if not the most important washer and drying machine leasing company. So, they require a very good service department for them. Thus, I would develop one very innovative service department with an online application that would allow performing this job with an outsourcing labor force making it cheaper or us. The recruitment would be based on the different washing machine brands certification as a service and repair provider technician. We would also select them based on consumer service orientation and will create a database on the platform. This platform would be categorized by county, let us offer it for our selected local service outsource technicians. We would make an agreement with them for the database in the form of a services contract that would set a diagnosis and a services fee. We would also have an inventory of machine parts and we would only charge 20% of the cost of the services. We would establish the fee and we would also sell the costumer the fee for the parts used to fix the machines.  

6 0
3 years ago
Which of the following activities are performed by computer programmers? Choose all that apply.
AleksAgata [21]

Answer:

- They write step by step instructions for a computer to follow.

- They create a logic problem that the computer program can solve.

3 0
3 years ago
1. Write a query to list the names all products (by product code and name) and the average ordered quantity for each product wit
r-ruslan [8.4K]

select WorkCenterId, Count (ProducedIn_t.ProductID) as 'TotalProducts' from ProducedIn_t left outer join Product_t on Product_t.ProductID=Product_t.ProductID group by WorkCenterId

8 0
4 years ago
Type the correct answer in each box. Spell all words correctly. Programmers utilize to convert a program from language, which is
natulia [17]

Answer: Binary

Explanation: Binary is a system of 1s and 0s that tell the system when and where to flip a digital switch very fast

3 0
3 years ago
Other questions:
  • ________ is the presentation of information to the user and the acceptance of the user’s commands. a.data storageb.data access l
    7·1 answer
  • Sarah's employer purchased a health insurance plan that costs $750 per month. Sarah pays $75 toward the plan each month. What is
    5·2 answers
  • Ella has finished drafting her presentation. What should she do next?
    6·2 answers
  • Help
    9·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is
    5·1 answer
  • What is the statement describing? Agile team continuously adapt to new circumstances and enhance the methods of value delivery
    6·1 answer
  • In mathematics, the square root of a negative number is not real; in Java therefore, passing such a value to the square root fun
    12·1 answer
  • Consider a two-link network where Host A is connected to the router by a 1 Mbps link with 10 ms propagation delay and the router
    6·1 answer
  • 3. Cellular phone technology works on a system of geographically separated zones
    12·1 answer
  • The ability to use various design software such as Adobe Photoshop, InDesign, and Illustrator would be MOST beneficial to which
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!