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
Rzqust [24]
3 years ago
11

Create an application (that uses the SortedABList) that allows a user to enter a list of countries that he or she has visited an

d then displays the list in alphabetical order, plus a count of how many countries are on the list. If the user mistakenly enters the same country more than once, the program should inform the user of their error and refrain from inserting the country into the list a second time.
Computers and Technology
1 answer:
gulaghasi [49]3 years ago
8 0

Answer:

import java.util.*;

public class Country

{

  public static void main(String args[])

  {

      char ch,temp;

      int flag = 0;

      String country;

      ArrayList<String> countries = new ArrayList<String>();

      Scanner sc = new Scanner(System.in);

      do

      {

          System.out.println("enter the country you have visited:\t");

          country = sc.next();

          for(int i=0;i<countries.size();i++)

          {

              if(countries.get(i).equals(country))

              {

                  System.out.println("you have already entered the country");

                  flag = 1;

                  break;      

              }

          }

          if(flag == 0)

          {

              countries.add(country);

              flag = 0;

          }

          System.out.println("want to add another country(y/n):\t");

          ch = sc.next().charAt(0);

      }while(ch!='n');

      Collections.sort(countries);

      System.out.println("Countries you have visited:\t"+countries);

      System.out.println("Total number of contries visited:"+countries.size());

     

  }

}

Explanation:

You might be interested in
We canconnect  two or more computer together using cables true or false​
jekas [21]

This is true for most modern computers

8 0
2 years ago
How to create a comparator generic type in java.
KIM [24]

Answer:

public class Person {

//fields

private int id;

private String name;

private Payment pay;

//constructor

public Person(String name, int id,

int startSal, int startBon){

this.name = name;

this.id = id;

this.pay = new Payment(startSal, startBon);

}

//method get name

public String getName(){

return name;

}

//method get id

public int getId(){

return id;

}

//method get start salary

public int getStartSalary(){

return pay.startSalary;

}

//method get start bonus

public int getStartBonus(){

return pay.startBonus;

}

//inner payment class

private class Payment{

int startSalary;

int startBonus;

public Payment(int sal, int bon){

this.startSalary = sal;

this.startBonus = bon;

8 0
2 years ago
Which of the following sets of data would be represented best in histogram?
wariber [46]
I think it would be B. The average monthly sales for the big toy company because its giving data over history
7 0
3 years ago
Read 2 more answers
What is the full form of ALU​
Alexandra [31]

Answer: arithmetic logic unit: the part of a central processing unit that performs arithmetic and logical operations.

Srry if it is wrong

I hope it  helps you

6 0
2 years ago
Read 2 more answers
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can_______ the appropriate
Masteriza [31]

Answer:

a. call

Explanation:

According to my research on function, I can say that based on the information provided within the question the program can call the appropriate function. A function is a piece of code that completes a single task when called upon. Calling is another way of just saying that your telling the function to run its code at that given moment.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

4 0
2 years ago
Other questions:
  • Which of the following is NOT a group on the Slide Master tab?
    6·1 answer
  • Martha wants to invite her coworkers to her birthday party. She uses the mail merge feature to compose and send the invitations.
    6·1 answer
  • _________ are represented using diamonds linked withparticipant ETs
    6·1 answer
  • Citing the recent increase in earnings by several computer companies, economists feel that a cycle has begun in which personal c
    13·1 answer
  • A(n) ________ CPU has two processing paths, allowing it to process more than one instruction at a time.
    9·2 answers
  • Service that connects on-premises software appliances with cloud based storage is ______
    10·1 answer
  • An image that has been saved in Tagged Image File Format (or .TIF) is A. readable only by Windows personal computers. B. a recto
    6·1 answer
  • Plz tell the answer I I'll mark u as the brainliest
    14·1 answer
  • WILL GIVE BRAINLIEST!!!!!! 10 POINTS!!!!
    14·2 answers
  • what is the term for software that is exclusively controlled by a company, and cannot be used or modified without permission?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!