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
Anna [14]
1 year 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]1 year 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
Why would Network Systems employees be employed by the government?
Ghella [55]
Well knowing how the government is with security id go with A. as it makes a lot of sense unlike B and D and if they were looking for software the question would mention it
8 0
2 years ago
Read 2 more answers
add is a method that accepts two int arguments and returns their sum. Two int variables, euroSales and asiaSales, have already b
Oduvanchick [21]

Answer:

// here is code in Java.

// package

import java.util.*;

// class definition

class Main

{

   // method that return sum of two sale value

   public static int Add(int euroSales,int asiaSales)

   {

       // return the sum

       return euroSales+asiaSales;

   }

   //main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // variables

       int euroSales=100;

       int asiaSales=150;

       int eurasiaSales;

        // call the function

       eurasiaSales=Add(euroSales,asiaSales);

        // print the sum

       System.out.println("total sale is:"+eurasiaSales);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare and initialize two variables "euroSales=100" and "asiaSales=150". Declare another variable eurasiaSales. Call the method Add() with euroSales and asiaSales as parameter. This method will add both the value and return the sum.This sum will be assigned to variable eurasiaSales.Then print the sum.

Output:

total sale is:250  

8 0
2 years ago
Organizations that have no physical ("brick and mortar") presence, but only exist because of communication and computer technolo
mylen [45]

Answer: Virtual Organisations

Explanation: Virtual Organisations are Organisations that do not have any physical presence (brick and mortar). They exist in Internet platforms, social media and are known through the use telecommunications systems and facilities. This type of organisations continously conduct their businesses and liaise with their customers only through virtual Communication platforms like the computer Communication systems.

7 0
2 years ago
Edhesive Assignment 3: Chatbot on Python
marta [7]

Answer:

Explanation:

Easy peasy lemon squeezy

print: ("hey how are you why are you what are you")

print: ("1,2,3:"):

eif: ("1"):

print: ("nothing")

eif: ("2"):

print: ("Well i am doing this")

eif: ("3):

print: ("watched pewdiepie")

4 0
1 year ago
Read 2 more answers
This subsystem defines the logical structure of the database by using a data dictionary or schema. multiple choice data manipula
zubka84 [21]
Data manipulation subsystem<span>provides tools for maintaining and analyzing data
</span>Application generation subsystem<span>provides tools to create data entry forms and specialized programming languages that combine with common and widely used programming languages
</span>Data administration subsystem<span>helps supervise the overall database; including maintenance of security, supplying disaster recovery support, and observing the overall performance of database operations</span>
7 0
2 years ago
Read 2 more answers
Other questions:
  • When a switch configuration includes a user-defined error threshold on a per-port basis, to which switching method will the swit
    13·1 answer
  • ____ refers to typing your entire e-mail message or discussion group post using only capital letters.
    15·1 answer
  • What kind of device can monitor a connection at the demarc but cannot interpret data?
    9·1 answer
  • Which of the following is NOT a method in which a macro can be run?
    10·1 answer
  • Match the vocabulary word to the accurate definition. A software program that enables you to search for, interact with, and retr
    5·2 answers
  • Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
    7·2 answers
  • Budget Analysis (use while loop) Write a program that asks the user to enter the amount that he or she has budgeted for a month.
    5·1 answer
  • Fill in the blanks to make the factorial function return the factorial of n. Then, print the first 10 factorials (from 0 to 9) w
    6·1 answer
  • Create two classes. The first, named Sale, holds data for a sales transaction. Its private data members include the day of the m
    8·1 answer
  • When do images or graphics in Microsoft Word hurt the document rather than help
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!