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
kakasveta [241]
4 years ago
10

Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in

alphabetical order, and displays the sorted words separated by spaces. Write a Main() to test this funciton. The SortAndDisplayWords method will be tested with one, two, five, and ten words
Computers and Technology
1 answer:
sp2606 [1]4 years ago
3 0

Answer:

Following are the program in the C# Programming language.

//header

using System;

//define class

public class SortWords

{//define function

 public static void Display_Words(string[] word)

 {//set string type variable

   string a;

   //set the for loop for swapping the words

   for (int i = 0; i < word.Length; i++)

   {//set the for loop

     for (int j = 0; j < word.Length - 1; j++)

     {

   //set the if conditional statement for compare the string

       if (String.Compare(word[j], word[j + 1], StringComparison.Ordinal) > 0)

       {

       //perform swapping

         a = word[j];

         word[j] = word[j + 1];

         word[j + 1] = a;

       }

     }

   }

   //print message

   Console.WriteLine("Sorted Words: ");

   //set for loop to print the sorted list

   for (int i = 0; i < word.Length; i++)

   {//print space between the sorted characters

     Console.Write(word[i] + " ");

   }

 }

//define the main function

 public static void Main()

 {//print message

   Console.Write("Enter the number of words: ");

   //get input from the user

   int get_size = Convert.ToInt32(Console.ReadLine());

   //set string type array

   string[] word = new string[get_size];

   Console.WriteLine("Enter " + get_size + " words");

   //set for loop to get input in string type array

   for (int i = 0; i < get_size; i++)

   {

     word[i] = Console.ReadLine();

   }

   //call the function

   Display_Words(word);

 }

}

<u>Output</u>:

Enter the number of words: 5

Enter 5 words

h

e

l

l

o

Sorted Words:

e h l l o

Explanation:

Here, we define a class named "SortWords" and inside the class.

  • Define void type function "Display_words" and pass an string data type array argument "word".
  • Inside the function, we set two for loops to swapping the words and inside it we set the if conditional statement to compare the words then, perform swapping.
  • Set the for loop to print the sorted list

Finally, we define the main function in which we get inputs from the user, firstly we get the number of words then we get the words from the user. then call the function "Display_words".

You might be interested in
Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
timama [110]

Answer:

The method in python is as follows:

class myClass:

    def printRange(min,max):

         for i in range(min, max+1):

              print("{"+str(i)+"} ", end = '')

           

Explanation:

This line declares the class

class myClass:

This line defines the method

    def printRange(min,max):

This line iterates from min to max

         for i in range(min, max+1):

This line prints the output in its required format

              print("{"+str(i)+"} ", end = '')

5 0
3 years ago
Review the HTML tags that we have gone over in this lesson. Research HTML tags on the web and identify two new tags. Use these t
NemiM [27]

Answer:

w3schools

Explanation:

there is a webiste called w3schools that really helped me through my web page design class, just click on learn html

4 0
3 years ago
Heather is troubleshooting a computer at her worksite. She has interviewed the computer’s user and is currently trying to reprod
Aleksandr [31]

Answer:

D. Identify the problem.

Explanation:

There are six steps or stages in computer system troubleshooting. They are,

1. Identify the problem: In the stage of troubleshooting, the user is interviewed to get a description of the problem. Reproducing the problem is essential to confirm the described problem of the system before moving to the next stage.

2. Establish a theory of probable cause: when the problem is identified, a list of the possible cause of the problem is made.

3. Test the theory to determine a cause: each items on the list of possible cause of the problem is tested to confirm its actual cause.

4. Resolve the problem.

5. Verify full system functionality

6. Document the findings, actions and outcomes.

8 0
4 years ago
How many numbers can be represented with 2,3,4,8 bits?
MrRa [10]
Image that a bit is the smallest measure in programming, such as an elementary particle in physics. So, a bit can only fit one number.
5 0
3 years ago
Compare the two types of formatting that IDE devices must go through. What is the primary difference between the two?
Andrei [34K]
A quick format<span> changes the file system while the </span>full format<span> also checks the </span>drive for bad sectors.  <span>The scan for bad sectors is the reason why the Full </span>format<span> takes twice as long as the </span>Quick format<span>. If you choose the </span>Quick format<span> option, the </span>format<span> removes address files from the partition, but does not scan the disk for bad sectors.</span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • Text, numbers,graphics, sounds entered into a computer's memory during input operations are referred to as
    11·1 answer
  • Electronic files created on a computer using programs such as word software are considered to be
    15·1 answer
  • Please help
    5·2 answers
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • Which key combination will allow users to move to the top of a document?
    15·1 answer
  • The federal government is the largest employer of cybersecurity professionals true or false
    5·1 answer
  • In cell M2, enter a formula using a nested IF function as follows to determine first if a student has already been elected to of
    12·1 answer
  • Which type of information could be displayed using this line graph?
    12·2 answers
  • I will make you brainless Just answer this question!!
    9·1 answer
  • If I bought mine craft p.e. for 7.99 and hook my Micro soft account up, will i get java edition
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!