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
Anna [14]
3 years ago
8

Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter th

e first city: Chicago Enter the second city: Los Angeles Enter the third city: Atlanta The three cities in alphabetical order are Atlanta Chicago Los Angeles
Computers and Technology
1 answer:
maria [59]3 years ago
3 0

Answer:

import java.util.Scanner;

public class SortStrings3 {

   public static void main(String args[]){

       Scanner scanner = new Scanner(System.in);

       String str1, str2, str3;

       System.out.print("Enter the first city: ");

       str1 = scanner.nextLine();

       System.out.print("Enter the second city: ");

       str2 = scanner.nextLine();

       System.out.print("Enter the third city: ");

       str3 = scanner.nextLine();

       System.out.print("The three cities in alphabetical order are ");

       if(str1.compareTo(str2) < 0 && str1.compareTo(str3) < 0){

           System.out.print(str1+" ");

           if(str2.compareTo(str3) < 0){

               System.out.print(str2+" ");

               System.out.println(str3);

           }

           else {

               System.out.print(str3+" ");

               System.out.println(str2);

           }

       }

       else if(str2.compareTo(str1) < 0 && str2.compareTo(str3) < 0){

           System.out.print(str2+" ");

           if(str1.compareTo(str3) < 0){

               System.out.print(str1+" ");

               System.out.println(str3);

           }

           else {

               System.out.print(str3+" ");

               System.out.println(str1);

           }

       }

       else{

           System.out.print(str3+" ");

           if(str1.compareTo(str2) < 0){

               System.out.print(str1+" ");

               System.out.println(str2);

           }

           else {

               System.out.print(str2+" ");

               System.out.println(str1);

           }

       }

   }

}

EXPLANATION:

Okay, we are given that a program should be written which will make user to enter three cities namely Atlanta, Chicago and Los Angeles (which should be done in ascending  alphabetical order).

So, we will be writting the code or program with a programming language known as JAVA(JUST ANOTHER VIRTUAL ACCELERATOR).

We will make use of java to write this program because Java can be used in Loading code, verifying codes and executing codes on a single or multiple servers.

The code or program can be seen in the attached file/document. Kindly check it.

Download doc
You might be interested in
Two middle-order batsmen are compared based on their performance in their previous cricket match.
Zolol [24]
How many points is this for
5 0
4 years ago
1-5. Discuss briefly the function and benefits of computer network. (5pts​
Elden [556K]

Computer networks allow an unlimited amount of computers to communicate with each other. This is especially useful in enterprise environments, as technicians have to deal with hundreds of computers at a time. Computer networks make it easier to share files, increase storage capacity, better communication, easier to to control computers remotely, easier to share resources, ability to share a single internet connection on multiple devices. Computer networks also have a lot of cost benifits too, as network administration is centralised, meaning that less IT support is required, and you can cut costs on sharing peripherals and internet access.

Hopefully this helps you out!

7 0
3 years ago
What correctly describes the features of the service called kickstarter?
Nikitich [7]

Kickstarter is a crowdfunding platform that offers opportunities for its users to financially invest in projects made by others users. The projects available are incredibly varied in terms of its product category ranging from technological innovations to board games. The platform has been around since 2009. Users who can post projects come from various countries, such as United Kingdom, United States, Spain, and even Hong Kong. To date, Kickstarter has managed to raise more than USD 1 billion for over 250,000 projects.

4 0
4 years ago
Read 2 more answers
Which wireless communication is typically limited to six feet of distance?
Tcecarenko [31]

Answer:

Bluetooth is a wireless communication    is  typically limited to   six feet distances

Explanation:

Bluetooth is one type of communication maximum it covers  10 meters to 30 meters.   but it is one to one communication made for data transactions.  After  25 meters of coverage on communication will be very slow on data transactions. But Bluetooth has also had a limitation.

IR.  It is one of communication where infrared technology used. It is like face to face communication and speed of data transaction limited and it is also one to one communication made for data transactions. Communication paired and covered very little distances.

NFC it is chip-based and covers very little in fact just to device meet each and communication started. And very it caries very little data during the data transactions. it is also one to one communication made for data transactions

RFID is one of communication and it is powerful to cover more areas with multiple connections at the same time. It has a limitation  in distance and it covers  like a net with a specific distance  

4 0
3 years ago
दूलह श्री रघुनाथ बने दुलही सिय सुंदर मंदिर माहीं।
svetlana [45]

Answer:

The bridegroom Shri Raghunath, Gavati Geet Sabai Mili Sundar Bed Juwa Jury Vipra Padhahin, Janaki, and Kankan.

Explanation:

8 0
3 years ago
Other questions:
  • The condition, ____, entered in the criteria row of a long text field in a query window would retrieve all records where the lon
    8·1 answer
  • A group of computers that are interconnected in order to share information or documents is called a _____
    9·1 answer
  • Write a program that prompts the user to input a number. The program should then output the number and a message saying whether
    10·1 answer
  • What information and options can be found on the File tab?
    8·1 answer
  • Which two tools used for incident detection can be used to detect anomalous behavior, to detect command and control traffic, and
    13·1 answer
  • 1. What does a network allow computers to share?
    13·1 answer
  • 1.Menciona tres factores o variables que consideras influirán en el oscurecimiento del alimento cortado o pelado expuesto a la i
    8·1 answer
  • Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the
    10·1 answer
  • Debug the code in the main method of this class, which is intended to initialize an array named arr to hold 3 ints, fill this wi
    15·1 answer
  • Spark is electrical discharge in air, while air is mix of variety of gases what particles conduct electricity in gas
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!