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
The local Driver's License Office has asked you to write
Y_Kistochka [10]

One of the most popular object-oriented programming languages is C++. Stroustrup created C++ by adding object-oriented features to the C programming language.

<h3>How do you write a program in C++?</h3>
  • Some people believe that the open-source C++ IDE Dev C++ is one of the finest. However, it may be used exclusively on Windows and macOS. It contains capabilities like profiling, integrated debugging, syntax highlighting, code completion, tool managers, and GCC-based compilers.
  • Many people believe that C++, an object-oriented programming (OOP) language, is the finest language for developing complex applications. The C language is a superset of C++.

#include <iostream>

#include <string>

#include <iomanip>

#include <cctype>

using namespace std;

class TestGrader

{

private:

string answer[20];

public:

void setKey(string[]);

void grade(string[]);

};

/*********************************************************************/

void TestGrader::setKey(string correct[])

{

for (int x = 0; x < 20; x++)

{

 answer[x] = correct[x];

}

}

void TestGrader::grade(string test[])

{

int right = 0;

int wrong = 0;

int count = 0;

for (int x = 0; x < 20; x++)

{

 if (test[x] == answer[x])

 {

  right += 1;

  count += 1;

 }

 else if (test[x] != answer[x])

 {

  wrong += 1;

 }

}

if (count >= 15)

{

 cout << "Congratulations you have passed the driver's license exam" << endl;

}

else

{

 cout << "You failed the driver's license exam" << endl;

}

cout << "You got a total of " << right << " right answers and a total of " << wrong << " wrong answers in the test" << endl;

cout << "You got questions ";

for (int x = 0; x < 20; x++)

{

 if (test[x] != answer[x])

 {

  cout << x + 1 << " ";

 }

}

cout << "wrong" << endl;

}

int main()

{

string answers[20] = { "B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A"};

TestGrader exam;

exam.setKey(answers);

string yourTest[20];

int choice;

do

{

 for (int x = 0; x < 20; x++)

 {

  cout << "Enter the answer for question " << x + 1 << ": ";

  cin >> yourTest[x];

  while (yourTest[x] > "D"  || yourTest[x] < "A")

  {

   cout << "Please enter from A-D: ";

   cin >> yourTest[x];

  }

 }

 exam.grade(yourTest);

 cout << endl << "Enter -1 to quit, else enter any number to retake the exam: ";

 cin >> choice;

} while (choice != -1);

return 0;

}

To learn more about C++ refer,

brainly.com/question/15411348

#SPJ4

6 0
1 year ago
A user is reporting to you that they are unable to run a script named script1 within their home directory. The user has ownershi
lianna [129]

The correct scripts are:

chmod 765 script1

chmod u+x script1

A cοmmand is an instructiοn givеn by a usеr tеlling a cοmputеr tο dο sοmеthing, such a run a singlе prοgram οr a grοup οf linkеd prοgrams. Cοmmands arе gеnеrally issuеd by typing thеm in at thе cοmmand linе (i.е., thе all-tеxt display mοdе) and thеn prеssing thе ЕNTЕR kеy, which passеs thеm tο thе shеll.

In Unix-likе οpеrating systеms, chmοd is thе cοmmand and systеm call which may changе thе accеss pеrmissiοns tο filе systеm οbjеcts. It may alsο altеr spеcial mοdе flags. Thе rеquеst is filtеrеd by thе umask. Thе namе is an abbrеviatiοn οf changе mοdе.

8 0
4 years ago
if you were writing an essay about the major rivers of America which illustration would be the most helpful to your reader ​
Dmitrij [34]

Answer:A map

Explanation: (╹◡╹)

4 0
3 years ago
Your job is to write a basic blurring algorithm for a video driver. The algorithm will do the following: it will go through all
nekit [7.7K]
I’m pretty sure answer is B let me know if I’m wrong
4 0
4 years ago
Frank is preparing a subsection of the SRS document that specifies data formats, data integrity, and storage capabilities. Which
Flauer [41]

The subsection which Frank is preparing for the SRS document that specifies data formats, data integrity, and storage capabilities is Logical Database Requirements.

<h3>What is SRS document?</h3>

SRS document of the software requirement specification document is the document which describes the function of a software and its procedure to perform a particular function.

Different types of requirement-

  • A. External Interface Requirements- This includes the interface of used, such as layout of screen, button etc.
  • B. Design Constraints- This includes the subcomponent of the system, such as performance requirement.
  • C. Inverse Requirements- It defines that what a system can not do.
  • D. Logical Database Requirements- Data of the user are saved in this such as profile, massage,data formats, data integrity, and storage capabilities etc.
  • E. Non-Functional Requirements-This includes attributes of system, performance, security etc.

Frank is preparing a subsection of the SRS document that specifies data formats, data integrity, and storage capabilities.

Thus, the subsection which Frank is preparing for the SRS document that specifies data formats, data integrity, and storage capabilities is Logical Database Requirements.

Learn more about the SRS document here:

brainly.com/question/26161636

#SPJ1

4 0
3 years ago
Other questions:
  • If there is no index.html file in the root folder nothing will be displayed when you navigate to the site address
    14·1 answer
  • In a clustered column chart, the names of each column are part of the ____ series. select one:
    11·1 answer
  • Can anyone drink and drive safely?
    13·2 answers
  • Which tab on the ribbon houses the sort functions?<br><br> Insert<br> Data<br> View<br> Home
    11·1 answer
  • PLEASE HELP THIS IS MY LAST CHANCE TO PASS MY QUIZ
    13·2 answers
  • John Cleaver is the CEO of Tech World, which is a retail store that sells computers, monitors, cameras, televisions and many oth
    6·1 answer
  • To use appropriate personal protective equipment we should​
    12·1 answer
  • so i am on a Chromebook with headphones , and I am wondering if you can make it that a tab only play sound on one side of the he
    12·1 answer
  • Differentiate the term, "bundling," as applied to a Mac/Apple computer and a PC.
    5·1 answer
  • PLEASE HURRY!!!<br> Look at the image below
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!