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
kakasveta [241]
2 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]2 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
A computer application such as Microsoft Access that is used to store data and convert it into information is a ________________
lorasvet [3.4K]
All data is stored in table
5 0
2 years ago
3.14 LAB: Simple statistics for Python
Ad libitum [116K]

Answer:

Following are the correct python code to this question:

n1 = float(input('Input first number: '))#input first number  

n2 = float(input('Input second number: '))#input second number  

n3 = float(input('Input third number: '))#input third number  

n4 = float(input('Input fourth number: '))#input fourth number  

average = (n1+n2+n3+n4)/4 #calculate input number average

product = n1*n2*n3*n4 # calculate input number product

print('product: {:.0f}  average: {:.0f}'.format(round(product),round(average))) #print product and average using round function

print('product: {:.3f}  average: {:.3f}'.format(product,average)) #print product and average value

Output:

Please find the attachment.

Explanation:

The description of the above python code can be defined as follows:

  • In the above python program four variable "n1, n2, n3, and n4" is defined, in which we take input from the user end, and in these user inputs we use the float method, that converts all the input value in to float value.
  • In the next step, two variable average and product are defined, that calculate all input numbers product, average, and hold value in its variable.
  • In the last line, the print method is used, which prints its variable value by using a round and format method.

8 0
2 years ago
Windows is displaying an error about incompatible hardware. You enter BIOS/UEFI setup to change the boot priority order so that
Irina18 [472]

Answer:

A

Explanation:

The most likely cause of the problem is that You signed in to BIOS/UEFI with the user power-on password rather than the supervisor power-on password. The User password only enables the machine to boot while the supervisor password allows entering the BIOS settings.

4 0
2 years ago
Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It shou
mario62 [17]

Solution :

class Employee:

   #Define the

   #constructor.

   def __$\text{init}$__($\text{self, nam}e$,  ID_number, $\text{salary}$, email):

       #Set the values of

       #the data members of the class.

       $\text{self.nam}e$ = name

       $\text{self.ID}$_number = ID_number

       $\text{self.salary}$ = salary

       self.email_address = email

#Define the function

#make_employee_dict().

def make_employee_dict(list_names, list_ID, list_salary, list_email):

   #Define the dictionary

   #to store the results.

   employee_dict = {}

   #Store the length

   #of the list.

   list_len = len(list_ID)

   #Run the loop to

   #traverse the list.

   for i in range(list_len):

       #Access the lists to

       #get the required details.

       name = list_names[i]

       id_num = list_ID[i]

       salary = list_salary[i]

       email = list_email[i]

       #Define the employee

       #object and store

       #it in the dictionary.

       employee_dict[id_num] = Employee(name, id_num, salary, email)

   #Return the

   #resultant dictionary.

   return employee_dict

6 0
2 years ago
Can you find the reason that the following pseudocode function does not return the value indicated in the comments? // The calcD
Alexus [3.1K]

Answer:

see explaination

Explanation:

Function Real calcDiscountPrice(Real price, Real percentage) // Calculate the discount.

Declare Real discount= (price * percentage) / 100.0 // Subtract the discount from the price.

//dividing by 100.0 because of % concept

Declare Real discountPrice = price - discount // Return the discount price.

Return discount End Function

5 0
2 years ago
Other questions:
  • Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In one to two sentences,
    9·2 answers
  • The ________ method is based on simple arithmetic. The process involves dividing the bits of a frame into equal segments, adding
    11·1 answer
  • Which type of word processing programs enables us to include illustrations within the program?
    6·1 answer
  • A company wants to publish Knowledge articles to its Customer Community. The articles should be organized for easy navigation by
    6·1 answer
  • You realize your computer has been infected with malware. It seems as if someone is controlling your computer from a remote loca
    5·1 answer
  • Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • Program MATH_SCORES: Your math instructor gives three tests worth 50 points each. You can drop one of the test scores. The final
    7·1 answer
  • [20 points] 3.3 Code Practice: Question 2
    7·1 answer
  • c Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in a
    10·1 answer
  • Finish the program to compute how many gallons of paint are needed to cover the given square feet of walls. Assume 1 gallon can
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!