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]
4 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]4 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
When discussing the data-modeling building blocks, anything (a person, a place, a thing, or an event) about which data are to be
Fynjy0 [20]

Answer:

When discussing the data-modeling building blocks, anything (a person, a place, a thing, or an event) about which data are to be collected and stored is referred to as an entity.

Explanation:

Entities, attributes, and relationships are the basic building blocks of all data models .

An entity is therefore described as anything, such as a person, place, thing, or event, about which data are to be collected and stored. They may be physical objects such as customers or products.

7 0
4 years ago
What are some recent inventions that have improved the quality of your life?
Eva8 [605]
Phones, they help me with school work and provide entertainment.
4 0
3 years ago
What is virtualization?
anzhelika [568]

Answer:

Virtualization refers to the act of creating a virtual version of something, including virtual computer hardware platforms, storage devices, and computer network resources.

Explanation:

I hope this was what you were looking for

3 0
3 years ago
Read 2 more answers
with the current computer development, explain 5th areas where computer is applied for the social economic dwvelopment in societ
AleksandrR [38]

Explanation:

just want points tbh but have a good day

7 0
3 years ago
Which of the following is NOT true about a savings account
Andrew [12]

Answer: Withdraws

Explanation:

You can withdraw how ever many times you want from a savings account

4 0
3 years ago
Other questions:
  • If you could make any blog, what would it be about and why?
    9·1 answer
  • Binary data is written in hexadecimal. For example, when creating a graphic for a website, colors are represented by six hexadec
    12·1 answer
  • if you could take on the role as game designer and could change or add some type of financial aspect about the game what would b
    6·1 answer
  • A search engine is the same as a browser.<br> \
    11·1 answer
  • How would you convert an integer value to a float value in Python?
    10·1 answer
  • What is the answer to this question?
    10·1 answer
  • Implement a Java program using simple console input &amp; output and logical control structures such that the program prompts th
    15·1 answer
  • You can divide the code for an application into logical parts by moving some of the code from the main() method to other _______
    8·1 answer
  • What are the 6 major forms that Energy can be grouped into?
    10·1 answer
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!