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
UNO [17]
3 years ago
10

Print the two strings in alphabetical order. Assume the strings are lowercase. End with newline. Sample output: capes rabbits im

port java.util.Scanner: public class OrderStrings { public static void main (String args) { String firstString: String secondString: firstString = "rabbits" secondString = "capes" /*Your solution goes here */ return: } }import java.util.Scanner;public class OrderStrings { public static void main(String[] args) { String firstString; String secondString; firstString = "rabbit"; secondString= "capes"; //String class in java provide string comparison function, use it, and get //your work done may even use brute force i.e using for loop and compare character by // character which will not good for the programming language which already have vast //predefined number of functions if(firstString.compareTo(secondString) < 0){ System.out.println(firstString + " " + secondString); } else{ System.out.println(secondString + " " + firstString); } return; }}
Computers and Technology
1 answer:
ValentinkaMS [17]3 years ago
4 0

Answer:

Following are the code to the given question:

import java.util.Scanner;//import package

public class OrderStrings // defining a class OrderStrings  

{

   public static void main(String[] args) //defining a main method

   {

       Scanner scnr = new Scanner(System.in);//defining a Scanner class object  

       String firstString;//defining a String variable

       String secondString; //defining a String variable

       firstString = scnr.next();//input value

       secondString = scnr.next();//input value

       if (firstString.compareTo(secondString) < 0)//use if to compare sting value

           System.out.println(firstString + " " + secondString);//print sting value  

       else//else block

           System.out.println(secondString + " " + firstString);//print sting value

   }

}

Output:

rabbits capes

capes rabbits

Explanation:

In this code a class "OrderStrings" is defined inside the class the main method is defined that declares the two string variable that uses the input method to input the string value and after input, it uses the conditional statement. Inside this compareTo method is declared that compare string value and prints the string value.

You might be interested in
How can edge computing be used to increase sustainability
nika2105 [10]

Edge computing be used to increase sustainability With Edge Computing the number of records traversing the network can be reduced greatly, freeing up bandwidth.

<h3>How is part computing sustainable?</h3>

Data centers devour an expected 2 hundred terawatt-hours (TWh) of power every year–extra than the power intake of a few countries. They additionally produce an expected 2% of all worldwide CO2 emissions. Edge Computing reduces network site visitors and records centre usage.

Data centres devour an expected 200 terawatt-hours (TWh) of power every year–extra than the power intake of a few countries. They additionally produce an expected 2% of all worldwide CO2 emissions.

Read more about the sustainability:

brainly.com/question/25350238

#SPJ1

4 0
2 years ago
Consider an array of integers consisting of the numbers: 8 12 19 32 45 55 67 72 89 90 92. Suppose the binary search algorithm is
ankoles [38]

Answer:

Answered below

Explanation:

Index of the first element compared to the key is 5. The element itself is 55.

This index is evaluated by the addition of the index of the first element which is 0(zero) and the the index of the last element which is 10.

( Index of the last element is determined by subtracting the one from the total number of elements)

After the addition, the result is divided by 2 to get the first index from which the binary search begins.

firstIndex = 0

lastIndex = array.length - 1

midpoint = (firstIndex + lastIndex) / 2

6 0
3 years ago
The hardware components of a computer system interact with each other by using which of the following?
Inga [223]
B it is b..............................................
6 0
4 years ago
Read 2 more answers
____ is the process of drawing a series of increasingly detailed DFDs, until all functional primitives are identified.
cupoosta [38]

Answer:

a. Leveling          

Explanation:

  • Leveling is also called decomposing.
  • It is a method to depict more detail in lower-level Data Flow Diagrams
  • It is the technique to expand or decompose DFDs into more details or levels to extract more information and identify all functional primitives until no further detail is required.
  • An information system can be comprised of multiple processes. Leveling partitions each process into sub-processes which identifies more details about the process with each level.
  • 0-level DFD: it starts with context diagram which depicts the whole system as a single process e.g. Grading system.
  • 1-level DFD: the context diagram is decomposed in this level. This means a single process is expanded into multiple processes which extracts more details about a process of a system.
  • 2- level DFD: this level decomposes the the process of level 1 going into further details.
  • This decomposition and expansion continues until no further details are required and all functional primitives are identified.
8 0
4 years ago
How many base cases are in the functionabove?
baherus [9]

Answer:

The answer is (b). 1.

Explanation:

In the code there is only 1 base case .

the base case is as following:-

if(n==0)

return 0;

this is the base case.

Base case is the most important statement in the function that uses recursion because without base case the recursion calls will keep on going and we will get a run time error.

5 0
3 years ago
Other questions:
  • Which of the following is an extension of the fill pattern Sunday,Tuesday?
    10·2 answers
  • What are the four basic operating principles of the information processing cycle?
    7·2 answers
  • Give a recursive algorithm for finding the sum of the<br> first n odd positive integers.
    8·1 answer
  • What are three responsibilities of an operating system? please answer quick!!!
    9·1 answer
  • Meaning of page break​
    8·1 answer
  • Cell A1 contains the formula "=10+D2". If you copied A1 to B3, what would be the formula in B3?
    10·2 answers
  • Why do i get message notifications but when i click on it it says i have no new messages?
    7·1 answer
  • The internet shopping cart is an example of which version of the web?
    11·1 answer
  • Most operating systems perform all of the following tasks except _____. a. displaying the Graphical User Interface b. indexing t
    13·1 answer
  • Which tab allows you to review the slideshow timings?<br> O Home<br> O View<br> O Review<br> O File
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!