Create an application (that uses the SortedABList) that allows a user to enter a list of countries that he or she has visited and 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.

Answers

Answer 1
Answer:

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:


Related Questions

You wrote a list of steps the user will take to perform a task. Which statement is true about this step?You have drawn pictures of what your screens will look like and identified the input-process-output that occurs on eachscreen.O Your app is functioning and ready to test.O You have defined a use case.O In this step, you defined your target audience and main goal.
The Clean Air Act Amendments of 1990 prohibit service-related releases of all ____________. A) GasB) OzoneC) MercuryD) Refrigerants
When a JSP page is compiled, what is it turned into?? Applet? Servlet? Application? Midlet
98 POINTS HELP ASAP PLEASE!!!!You have been asked to create a program for an online store that sells their items in bundles of five. Select the appropriate code that would display how many bundles are available for sale.A.print(5 // totalItems)B.print(totalItems // 5)C.print(totalItems(5) )D.print(5(totalitems) )
A common measure of transmission for digital data is the number of bits transmitted per second. Generally, transmission is accomplished in packets consisting of a start bit, a byte (8 bits) of information, and a stop bit. Using these facts, answer the following:a. Compute the time required to transmit an image of 1200x800 pixels with 8 bits for gray of each pixel using a 50 M bits/sec. modem?b.What would the time be at 3 M bits/sec, a representative of download speed of a DSL connection?(c) Repeat a and b when the image is RGB colored with 8 bits for each primary color. f 20 colored frames per second

Consider the following instruction: OR( %1111_0000, AL ) ; After its execution, what will be true about the bits stored in AL?

Answers

Answer:

the higher order bits in AL will be true

Explanation:

We know from the truth table that in an OR operation, once one operand is true the result is true, no matter the value of the other operand. From the above AL will have the higher order bits to be true since the first four higher order bits are 1s, 1111_0000, this is regardless of the original values of AL. We cannot however ascertain if the lower bits of AL are true from this. Note 1 evaluates to true while 0 is false

What is touch-typing?typing with a keyboard shortcut
typing with macros
typing with only one hand
typing without looking at the keyboard

Answers

Typing without looking at the keyboard and using all fingers. I do this, so I'm 99% that's the correct answer.
Typing without looking at the keyboard.

Last one

Suppose two hosts, A and B, are separated by 7,500 kilometers and are connected by a direct link of R = 10 Mbps. Suppose the propagation speed over the link is 2.5 x 10 8 meters/sec. Consider sending a large packet of 500,000 bits from Host A to Host B. How many milliseconds (ms) does it take before the receiver has received the entire 500,000-bit file?

Answers

Answer:

50 ms (milliseconds) will be taken in total to take the entire file by user.

Explanation:

In Computer networks, propagation delay is defined as the time in which a packet is sent from sender to receiver completely. It is computed by taking the ratio of link length and propagation speed.

We know that:

BDP(in bits) = total bandwidth (in bits/sec) * trip time(in sec)

Now according to given condition we have:

Bandwidth = R = 10 Mbps = 10,000,000 bps

BDP = 500,000 bits

For finding Propagation Delay:

Propagation Delay = BDP/ R

Propagation Delay = 500,000/10,000,000 sec

Propagation Delay = 0.05 sec

Converting in milliseconds:

Propagation Delay = 50 ms

Hence. the delay would be 0.05 seconds and in milliseconds they will be equal to 50 ms

Write a program which increments from 0 to 20 and display results in Decimal on the console 2-b) Modify above program to increment from 0 to 20 and display results in Binary on the console

Answers

Answer:

This program is written in C++

Comment are used to explain difficult lines

The first program that prints 0 to 20 (in decimal) starts here

#include<iostream>

int main()

{

//Print From 0 to 20

for(int i = 0;i<21;i++)

{

 std::cout<<i<<'\n';

}

}

The modified program to print 0 to 20 in hexadecimal starts here

#include<iostream>

using namespace std;

int main()

{

//Declare variables to use in conversion;

int tempvar, i=1,remain;

//Declare a char array of length 50 to hold result

char result[50];

//Print 0

cout<<"0"<<endl;

// Iterate from 1 to 20

for(int digit = 1; digit<21; digit++)

{

//Start Conversion Process

//Initialize tempvar to digit (1 to 20)

tempvar = digit;

while(tempvar!=0)

{

//Divide tempvar by 16 and get remainder

remain = tempvar%16;

if(remain<10)

{

 result[i++]=remain + 48;

}

else

{

 result[i++] = remain + 55;

}

//Get new value of tempvar by dividing it by 16

tempvar/=16;

}

//Print result

for(int l=i-1;l>0;l--)

{

cout<<result[l];

}

i=1;

cout<<endl;  

}

return 0;

}

//The Program Ends Here

See Attachments for program 1 and 2; program 2 is the modified version of 1

How are you going to use computer in your career/field?

Answers

Answer:

Well, I am studying software engineering and ethical hacking, with the terms I mentioned it is very self explanatory how I use computers for those fields. In case it is still not self explanatory, we use computers to make software and websites accessing tools that can only be access using a computer and a working internet connection is required. Ethical hacking requires a computer to test the website or application security in order to do that we need a active internet connection in order to access the website itself.

Explanation:

i dont really know i am not really sure what i qill be in the future

Write a python program to calculate and print the electric bill for Ethiopian Electricity Corporation. (consumer name meter number(mno),last month reading(Imr)and current month reading(cmr) of 50 customers and calculate the net bill amounts as follows: Number of unit(Nou)=cmr-lmr If Nou200 then bill =Nou*2 tax=bill*0.15 netbill=bill+tax Print all the details in the bill for all customers​

Answers

The electric bill program illustrates the use of loops (i.e. iteration)

Loops are used to execute repetitive operations

The electric bill program in Python where comments are used to explain each line is as follows:

#This iteration shows that the process is repeated for 50 consumers

for i in range(50):

   #This gets input for the consumer name meter number

   mno = input("Consumer name meter number: ")

   #This gets input for last month reading

   lmr = int(input("Last month reading: "))

   #This gets input for current month reading

   cmr = int(input("Current month reading: "))

   #This calculates the number of units

   Nou = cmr - lmr

   #This calculates the bills

   bill = Nou*2

   #This calculates the tax

   tax = bill*0.15

   #This calculates the netbills

   netbill = bill+tax

   #This next four lines print the electric bills

   print("Number of units:",Nou)

   print("Bills:",bill)

   print("Tax:",tax)

   print("Netbill:",netbill)

Read more about loops at:

brainly.com/question/19344465