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
pantera1 [17]
3 years ago
13

[Java] Using the comparable interface

Computers and Technology
1 answer:
nadezda [96]3 years ago
7 0

Answer:

Check the explanation

Explanation:

public class Person implements Comparable<Person> {

   private String name;

   public Person(String name) {

       this.name = name;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this. name = name;

   }

   Override

   public int compareTo(Person o) {

       return name.compareTo(o.name);

   }

}

Person 1 ester..) aua .

import java.util.Scanner;

public class PersonTester {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       Person[] people = new Person[10];

       for (int i = 0; i < people.length; i++) {

           System.out.print("Enter name of person " + (i+1) + ": ");

           people[i] = new Person(in.nextLine());

       }

       Person first = people[0], last = people[0];

       for (int i = 0; i < people.length; i++) {

           if (people[i].compareTo(first) < 0) first = people[i];

           if (people[i].compareTo(last) > 0) last = people[i];

       }

       System.out.println("First person is " + first.getName());

       System.out.println("Last person is " + last.getName());

       in.close();

   }

}

You might be interested in
Give me username ideas for rblx.
alexandr1967 [171]

Answer: Larz7, Dracofli0, butterbro171,OVOclan1011, ect.

Explanation:

4 0
2 years ago
Read 2 more answers
The following statement calls a function named half, which returns a value that is half
nadezda [96]

Answer:

function half(number) {

     let result = number/2;

     return result;

}

Explanation:

4 0
3 years ago
A device is sending out data at the rate of 1000 bps. How long does it take to send
vredina [299]

Answer:

0.01 second ; 0.008 seconds; 800 seconds

Explanation:

Given that:

Sending rate = 1000 bps

Rate of 1000 bps means that data is sent at a rate of 1000 bits per second

Hence, to send out 10 bits

1000 bits = 1 second

10 bits = x

1000x = 10

x = 10 / 1000

x = 0.01 second

2.)

A single character 8 - bits

1000 bits = 1 second

8 bits = (8 / 1000) seconds

= 0.008 seconds

3.)

100,000 characters = (8 * 100,000) = 800,000

1000 bits = 1 second

800,000 bits = (800,000 / 1000)

= 800 seconds

4 0
2 years ago
What does ‘‘negotiation’’ mean when discussing network protocols? give an example?
rewona [7]
Some protocols have multiple algorithms to choose from for e.g., cryptographic purposes. During connection set up, client and server negotiate which one they'll use.

One example is the set up of a TLS connection. During the handshake, the client shares a list of its supported ciphers (the 'ciphersuites'). The server responds by indicating the best one that both sides support.

4 0
3 years ago
Which of the following is a characteristic of the college savings plan
Hoochie [10]

add the choices please

8 0
3 years ago
Read 2 more answers
Other questions:
  • Is a protocol that allows users to log on to and access a remote computer?
    8·1 answer
  • Which of the following branches of government is NOT involved in Discretionary Fiscal Policy?
    8·1 answer
  • PLEASE HELP!
    12·2 answers
  • Which of the following code displays the area of a circle if the radius is positive. a. if (radius != 0) System.out.println(radi
    11·1 answer
  • Program documentation _____.
    8·1 answer
  • How do u know when a website doesnt like u?
    11·1 answer
  • You can align controls in the report design window using the align button on the report design tools ____ tab.
    8·1 answer
  • Which visual aids can be used to present large amounts of numerical data from multiple sources? Check all that apply.
    7·1 answer
  • Define two benefits to members of the community of replacing the printed copy with an online version.
    5·1 answer
  • Why should we learn Ethereum? Explain.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!