answer.
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
Nataly_w
16 days 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:
amid [800]16 days 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:

The task requires creating a program that will prompt users to input three cities named Atlanta, Chicago, and Los Angeles (which are to be sorted in ascending alphabetical order).

Thus, we're going to develop the code using a programming language called JAVA (JUST ANOTHER VIRTUAL ACCELERATOR).

We chose Java for this task because it is capable of loading, validating, and executing code on either single or multiple servers.

The code can be found in the attached document/file. Please take a look at it.

Download doc
You might be interested in
6. A small design agency you are consulting for will be creating client websites and wants to purchase a web server so they can
amid [800]

Answer:

Clarification:

The most effective recommendation for the agency would be to ensure they fully grasp the overall ownership costs of the server. This encompasses not only the server itself but also various factors including necessary software, an IT server manager, facility expenses, security investments, and backup options. Although these are key costs they will face, there may be additional unexpected expenses. Consequently, the best approach is to supply them with comprehensive information for making an informed decision.

3 0
18 days ago
Sketch the developments in multimedia. What do you expect to be the commercial impact of multimedia in the (near) future?
Natasha_Volkova [897]

Answer:

Multimedia has become an essential and vital part of various sectors such as healthcare, education, entertainment, and marketing.

Explanation:

In the past, children primarily learned using textbooks, but now they engage with smart boards and other interactive digital devices that provide animated content.

The role of multimedia is crucial in entertainment, where there has been a significant increase in attendance for multimedia events.

Similarly, in the medical field, students can learn more effectively with the use of multimedia tools. Looking ahead, multimedia is expected to draw interest across all disciplines and its future seems promising.

4 0
17 days ago
Write a code segment to change the name of the Thing object something such that the new name consists of the old name with one c
oksian1 [797]

Answer:

import random

def name_change( name: list ) -> list :

   choice = random.choice( name )

   choice_index = name.index( choice )

   name.pop( choice_index )

   return name

Explanation:

The provided Python code utilizes the random library to randomly select an item from a list within the function "name_change". The index of the selected item is then retrieved from the list and removed from the original list called "name", with the modified name subsequently returned.

To activate the function, assign it to a variable, supply a list (it must be a list) as its argument, and then express the result.

6 0
1 month ago
If a packet gets “sucked down a black hole” (figuratively speaking) and is not received by its sender, and no message is sent ba
Harlamova29_29 [932]

If a packet gets figuratively “sucked into a black hole” and is not received by the original sender, with no message returned to clarify the situation, there is an issue. This lack of communication indicates there is a problem with the _____.

A.) ICMP

B.) TCP/IP

C.) HTTP

D.) ISO

A.) ICMP

I hope this information is useful and wish you the best.

~May

0 0
1 month ago
Use the following data definitions data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE" What will
Natasha_Volkova [897]

Answer:

Given Data:

myBytes BYTE 10h, 20h, 30h, 40h

myWords WORD 3 DUP(?), 2000h

myString BYTE "ABCDE"

From the supplied information, we can derive that:

(a).     a. EAX = 1

         b. EAX = 4

         c. EAX = 4

         d. EAX = 2

         e. EAX = 4

         f. EAX = 8

         g. EAX = 5

8 0
18 days ago
Other questions:
  • The compare_strings function is supposed to compare just the alphanumeric content of two strings, ignoring upper vs lower case a
    15·1 answer
  • Which of the following is true of how computers represent numbers?
    9·2 answers
  • PLEASE HELP!!~~
    7·1 answer
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • A company requires an Ethernet connection from the north end of its office building to the south end. The distance between conne
    8·1 answer
  • You work for a car rental agency and want to determine what characteristics are shared among your most loyal customers. To do th
    10·1 answer
  • Which of the following is opened when the Find command is clicked?
    12·1 answer
  • In a survey of 7200 T.V. viewers, 40% said they watch network news programs. Find the margin of error for this survey if we want
    6·1 answer
  • Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
    13·1 answer
  • When long labels are required, which of these commands can you use to improve readability of a worksheet?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!