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
How to write a program to draw 1000 random points on a frame in python language for coding?
harina [27]

Answer:

You could generate random numbers between the pixel amount of the height and width than place the dots at those random points

Explanation:

Do you need the code or can you make it using my "headstart"

8 0
3 years ago
____________ is a widely accepted international best practices framework for implementing information systems security.
balandron [24]

Answer:

Control Objectives for Information and related Technology (COBIT)

Explanation:

COBIT is a framework developed by the ISACA for managing and supervising Information Technology processes. Such kinds of frameworks allow companies to position themselves with the expectations that they and their clients expect. COBIT's aim is to provide management and business process owners with an IT control and governance model that helps deliver value from IT and identify and handle the IT-related risks. It helps bridge the gap between business needs, control requirements and technical issues. It is a paradigm of control for addressing the IT governance requirements and maintaining the security of knowledge and information systems. COBIT emphasizes on what allows processes to work well.

8 0
4 years ago
Java:
Agata [3.3K]

Answer:

import java.util.*;

public class work {

// function for counting unique character

public static int numUnique(String input) {

boolean[] list = new boolean[Character.MAX_VALUE];

for (int i = 0; i < input.length(); i++) {

list[input.charAt(i)] = true;

}

int count = 0;

for (int i = 0; i <list.length; i++) {

if (list[i] == true){

count++;

}

}

return count;

}

public static void main(String args[])

{

List<String>list=new ArrayList<>(); // creatng array list of type string

list.add("abcdef");

list.add("aaabcd");

list.add("bccddee");

list.add("abcddd");

list.add("a");

for(String str:list)

{

// for printing the results

System.out.println("given string : "+ str+" , number of unique values :"+numUnique(str));

}

}

}

Explanation:

5 0
4 years ago
I need a quick way to see all hardware connected to my computer.
timofeeve [1]
Look it up..............
7 0
3 years ago
Question # 7 Dropdown Select the correct word to complete the sentence. The original ARPANET had four nodes and connected groups
attashe74 [19]

Answer:

Facility

Explanation:

This is the answer because you can spell it out with Horizon.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Two electronics technicians are looking at the piece of testing equipment shown in the figure above. Technician A says that this
    10·1 answer
  • She thinks it is a good idea to list the gasses bass ed on the the gas found in the atmosphere ...
    12·1 answer
  • After running a Google Search Ads campaign for several months, Meredith notices sales of her advertised products are starting to
    8·1 answer
  • Which layer includes the physical transmission medium (cables or wireless media) that any network must use to send and receive t
    8·1 answer
  • At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase
    12·1 answer
  • Motivational appeals refer to
    15·1 answer
  • Which of the following describes a potentially damaging computer program that affects, or infects, a computer negatively by alte
    9·2 answers
  • Managers can use __ software to discuss financial performance with the help of slides and charts
    11·1 answer
  • Directions: Asba student of Contact Center Service, you already have an experience using different computer programs. Try to rem
    8·2 answers
  • Answer this pls ASAP
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!