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
Which elements of a myth appear in this story from early babylon
g100num [7]
-a setting that may be fake
- Supernatural being/character
- Conflict/ the plot of the story
7 0
3 years ago
The Fed: decreases the money supply when the economy contracts. performs banking services for commercial banks in districts wher
Slav-nsk [51]

Answer:

performs banking services for commercial banks in districts where it operates.

Explanation:

The Federal Reserve System ( popularly referred to as the 'Fed') was created by the Federal Reserve Act, passed by the U.S Congress on the 23rd of December, 1913. The Fed began operations in 1914 and just like all central banks, the Federal Reserve is a United States government agency.

Generally, it comprises of twelve (12) Federal Reserve Bank regionally across the United States of America.

Hence, the Fed performs banking services for commercial banks in districts where it operates, as well as providing services to the general public.

4 0
3 years ago
You are configuring a wireless network with two wireless access points. Both access points connect to the same wired network. Yo
krok68 [10]

Answer:

have the same SSID but different channels

Explanation:

Based on the information provided within the question it can be said that the best option to accomplish this would be to have the same SSID but different channels. This would maintain the users connected to the same network name (SSID) but still be able to roam and jump from one access point to the other.

7 0
3 years ago
Read 2 more answers
The template code provided is intended to take two inputs, x and y, from the user and print "pass" if one or more of the followi
just olya [345]

import java.util.Scanner;

public class U3_L6_Activity_Two{

   public static void main(String[] args){

       Scanner scan = new Scanner(System.in);

       int x = scan.nextInt();

       int y = scan.nextInt();

       if(x>=4|| ((y < 5) && ((x+y) < 7))){

           System.out.println("pass");

       }

   }

}

I'm pretty sure this is what you're looking for. Best of luck.

7 0
3 years ago
Recursion does NOT take place if any of the following happen:
Kruka [31]

Recursion does NOT take place if any of method A calls method B, which calls method A

II. method A calls method B, which calls method A

<u>Explanation:</u>

Recursion is function is function which is used to call a same function by itself by multiple times with certain condition or loops.

These type of function extremely used on data structure or virus (TSR). Purpose of the function is repeated process and checks the validation and exit by true or false.

In programming languages such as c or c++, vb.net, c# is used to menu organizations so the same function is called and used so the end user don’t write separate function for each times. In case end user has not doesn’t proper exit method on recursion function system either hang or real task to exits.

3 0
3 years ago
Other questions:
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • How do you solve this.
    12·1 answer
  • For a wire with a circular cross section and a diameter = 3.00mm calculate the following: (m means meter. mm means millimeter. c
    5·1 answer
  • Which of the choices Sean are not true when considering virus behavior
    9·1 answer
  • The if statement regards an expression with the value 0 as __________.
    13·1 answer
  • You are about to repair and change the resistor (small components),but the components are too small to solder and hold,what tool
    12·1 answer
  • PROGRAM LANGUAGE C
    5·1 answer
  • I need this answered
    10·1 answer
  • ________is the most popular public key algorithm available and can be used for digital signatures, key exchange, encryption, and
    10·2 answers
  • Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!