Write a client program ClientSorting2 and in the main() method: 1. Write a modified version of the selection sort algorithm (SelectionSorter()) that sorts an array of 23 strings (alphabetically) rather than one of integer values. Print the array before it is sorted in the main() method, then after it is sorted in SelectionSorter().

Answers

Answer 1

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

 public static void SelectionSorter(String[] my_array){

     System.out.print("\nAfter sort: ");

     for (int ind=0; ind < 22; ind++ ){

         int min = ind;

         for (int k=ind+1; k < 23; k++ )

         if (my_array[k].compareTo(my_array[min] ) < 0 ){ min = k;  }

         String temp = my_array[ind];

         my_array[ind] = my_array[min];

         my_array[min] = temp;    }

   for (int j=0; j < 23; j++){   System.out.print(my_array[j]+" ");}

    }

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 String [] myarray = new String [23];

 for(int i= 0;i<23;i++){ myarray[i] = input.nextLine();  }

 System.out.print("Before sort: ");

 for ( int j=0; j < 23; j++ ){        System.out.print(myarray[j]+" ");    }

 SelectionSorter(myarray);

}

}

Explanation:

This defines the function

 public static void SelectionSorter(String[] my_array){

This prints the header for After sort

     System.out.print("\nAfter sort: ");

This iterates through the array

     for (int ind=0; ind < 22; ind++ ){

This initializes the minimum index to the current index

         int min = ind;

This iterates from current index to the last index of the array

         for (int k=ind+1; k < 23; k++ )

This compares the current array element with another

         if (my_array[k].compareTo(my_array[min] ) < 0 ){ min = k;  }

If the next array element is smaller than the current, the elements are swapped

         String temp = my_array[ind];

         my_array[ind] = my_array[min];

         my_array[min] = temp;    }

This iterates through the sorted array and print each array element

   for (int j=0; j < 23; j++){   System.out.print(my_array[j]+" ");}

    }

The main begins here

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

This declares the array

 String [] myarray = new String [23];

This gets input for the array elements

 for(int i= 0;i<23;i++){ myarray[i] = input.nextLine();  }

This prints the header Before sort

 System.out.print("Before sort: ");

This iterates through the array elements and print them unsorted

 for ( int j=0; j < 23; j++ ){        System.out.print(myarray[j]+" ");    }

This calls the function to sort the array

 SelectionSorter(myarray);

}

}


Related Questions

Explain the paging concept and main disadvantages of pipelined
approaches? Compare the superscalar and super pipelined approaches
with block diagram?

Answers

Answer:

PAGINACIÓN En la gestión de memoria con intercambio, cuando ... Debido a que es posible separar los módulos, se hace más fácil la modificación de los mismos. ... Ventajas y Desventajas de la segmentación paginada

Explanation:

what of the following uses heat from deep inside the earth that generates steam to make electricity​

Answers

Answer:

Geothermal power plants.

Explain what an IM is,

Answers

Answer: Stands for "Instant Message." Instant messaging, or "IMing," as frequent users call it, has become a popular way to communicate over the Internet

Explanation:

From the philosophical standpoint, especially in the discussion of moral philosophy or ethics, why do we consider “murder” or “killing” wrong or bad?

Answers

Explanation:

Morality is a set of values ​​and habits that a society acquires over time and can be categorized as good and bad values, right and wrong, justice and crime. Ethics is defined as the study of morals, the practical application of moral behaviors defined by society.

Therefore, the concept of "murder" or "killing" is seen as an immoral act by the vast majority of society around the world, strengthened by the set of moral conduct common to all human beings, which are the Articles on the Universal Declaration of Human Rights. Human Rights, which is an official document of the UN, which contains several universair and analytical rules on the rights of every individual, such as the right to life, security, freedom, etc.

If D3=30 and D4=20, what is the result of the function
=IF(D4 D3, D3-D4, "FULL")?
0-10
O Unknown
O 10
O Full

Answers

Answer:

c. 10

Explanation:

Given

[tex]D3 = 30[/tex]

[tex]D4 = 20[/tex]

Required

The result of: [tex]=IF(D4 < D3,D3-D4,"FULL")[/tex]

First, the condition D4 < D3 is tested.

[tex]D4 < D3 = 20 < 30[/tex]

Since 20 < 30, then:

[tex]D4 < D3 = True[/tex]

The condition is true, so:

D3 - D4 will be executed.

[tex]D3 - D4 = 30 - 20[/tex]

[tex]D3 - D4 = 10[/tex]

Hence, the result of the function is 10

Implement a class Clock whose getHours and getMinutes methods return the current time at your location. (Call java.time.LocalTime.now().toString() and extract the time from that string.) Also provide a getTime method that returns a string with the hours and minutes by calling the getHours and getMinutes methods. Provide a subclass WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock(3) should show the time in New York, three time zones ahead. Which methods did you override

Answers

Answer:

Explanation:

The following code was written in Java. It uses the LocalTime import to detect the current time. Then it creates a getHours, getMinutes, and getTime method to correctly print out only the hours and minutes in a simple format. Then it does the same for the WorldClock subclass which takes in the time offset as an int parameter and adds that to the hours in your own timezone.

class Clock {

   public String getHours() {

       String hours = java.time.LocalTime.now().toString().substring(0,2);

       return hours;

   }

   public String getMinutes() {

       String min = java.time.LocalTime.now().toString().substring(3,5);

       return min;

   }

   public String getTime() {

       String time = getHours() + ":" + getMinutes();

       return time;

   }

}

class WorldClock extends Clock {

   int timeZone = 0;

   public WorldClock(int timeZone) {

       super();

       this.timeZone = timeZone;

   }

   public String getHours() {

       String hours = String.valueOf(Integer.parseInt(super.getHours()) + 3);

       return hours;

   }

   public String getTime() {

       String time = getHours() + ":" + super.getMinutes();

       return time;

   }

}

class Test {

   public static void main(final String[] args) {

       Clock myClock = new Clock();

       System.out.println("My Time: " + myClock.getTime());

       WorldClock worldClock = new WorldClock(3);

       System.out.println("My Time + 3: " + worldClock.getTime());

   }

}

What type of information is best suited for infographies?​

Answers

Answer:

All varieties of information, from bullet pointed text to numerical tables

Explanation:

Answer:

All varieties of information, from bullet pointed text to numerical tables

Explanation:

Many individuals and organizations are choosing cloud storage for their important files. Discuss the pros and cons of cloud storage for both personal files and business files. Many individuals and organizations are choosing cloud storage for their important files. Discuss the pros and cons of cloud storage for both personal files and business files. What inputs and outputs are needed to support the storage environment

Answers

Answer:

Pros of cloud storage

Files can be accessed remotely without having to be connected to a company's intranetSecurity and file backups are managed by the cloud storage company, frees up employees time applying updates and other maintenance tasks.Usually billed monthly which allows for a lower initial startup cost

Cons of cloud storage

File security relies upon trust in the cloud storage providerLong term cost could be higher than storing files yourselfRequires an internet connection to access files

explain the different type of shift register counter ​

Answers

Answer:

Shift registers are also used as counters. There are two types of counters based on the type of output from right most D flip-flop is connected to the serial input. Those are Ring counter and Johnson Ring counter.

There are two types of shift register counters. They are given below:

Ring counter.Johnson ring counter.

What do you mean by Shift register counter?

The shift register counter may be defined as a sequence of a specific number of core registers that are significantly interconnected to one another in order to provide a clock-driven data shift.

A shift register is a set of f FFs that can be connected within the series and the stored data can be moved in the registers sequentially as per the command or instruction is given.

They are also utilized as counters. The type of shift register counter is based on the output from the D flip-flop which is connected to the serial input from the rightmost side.

Therefore, the two types of shift register counters are well mentioned above.

To learn more about Shift register, refer to the link:

https://brainly.com/question/14096550

#SPJ6

briefly explain 5 software which is either free or fee​

Answers

Answer:

65

Explanation:

Answer:

65

Explanation:

(Hours, minutes, and seconds) Write a method that returns a string in the form of hour:minute:second for a given total seconds using the following header:
public static String format(long seconds)
Here is a sample run:

Enter total seconds: 342324
The hours, minutes, and seconds for total seconds 342324 is 23:05:24

Note that a zero is padded to hour, minute, and second if any of these values is a single digit.

Answers

Answer:

Answered below.

Explanation:

class Convert {

public static String format(long seconds) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter total seconds: ");

int secs = sc.nextInt();

int hours = secs / 3600;

int minutes = (secs % 3600) / 60;

int seconds = (secs % 3600) % 60;

String timeFormat = hours + ":" + minutes + ":" + seconds;

return timeFormat;

}

}

HELP ASAP DONT ANSWER WITH A LINK​

Answers

Answer:

Layout

title

title and content

section header

comparison

Orientation

landscape

portrait

I have this project and I can't do anything about it, I do really need help ASAP

Answers

sorry i can't i am confused

How was the first computer reprogrammed

Answers

Answer:

the first programs were meticulously written in raw machine code, and everything was built up from there. The idea is called bootstrapping. ... Eventually, someone wrote the first simple assembler in machine code.

Explanation:

I need help solving this problem on Picoctf. The question is What happens if you have a small exponent? There is a twist though, we padded the plaintext so that (M ** e) is just barely larger than N. Let's decrypt this: ciphertext. The ciphertext is this. I tried using stack flow and the rsatool on GitHub but nothing seems to work. Do you guys have any idea of what I can do. I need to solve this problem asap

Answers

Explanation:

Explanation:

RSA encryption is performed by calculating C=M^e(mod n).

However, if n is much larger than e (as is the case here), and if the message is not too long (i.e. small M), then M^e(mod n) == M^e and therefore M can be found by calculating the e-th root of C.

If a 9V, 7W radio is on from 9am to 12pm. Calculate the amount of charge that flows through it, hence or otherwise the total number of free electrons that pass through at a point at the power supply terminals​

Answers

Answer:

Q=It

and

p=IV

Given, v=9V P= 7W

I=P/V

I =7/9

Also, time(t) from 9am to 12pm is 3hrs

Converting into sec =3×3600

t=10800

Q= 7/9 ×10800

Q =8400C

Explain the term software dependability. Give at least two real-world examples which further elaborates
on this term. Do you think that we can ignore software from our lives and remain excel in the modern
era? What is the role of software in the current pandemic period?

Answers

Answer:

Explanation:In software engineering, dependability is the ability to provide services that can defensibly be trusted within a time-period. This may also encompass mechanisms designed to increase and maintain the dependability of a system or software.Computer software is typically classified into two major types of programs: system software and application software.

Which of the following describes the line spacing feature? Select all that apply. adds space between words adds space between lines of text adds space between paragraphs adds space at the top and bottom of a page adds bullet points or numerical lists

Answers

Answer:

adds space between lines of text

adds space between paragraphs

Explanation:

Write a program that asks for the user's name, phone number, and address. The program then saves/write all information in a data file (each information in one line) named list.txt. Finally, the program reads the information from the file and displays it on the screen in the following format: Name: User's Name Phone Number: User's Phone Number Address: User's Street Address User's City, State, and Zip Code g

Answers

Answer:

Amazon prime

Explanation:

If you are insured with third party insurance, it will cover which costs?

A. business losses due to a denial-of-service attack
B. loss of data in your laptop because of a coffee spillover
C. ransomware attack on your laptop
D. costs related to lawsuits, and penalties due to a cyberattack

Answers

Answer:

c.

Explanation:

Answer: D (costs related to lawsuits, and penalties due to a cyberattack)

Explanation: Third Party insurance covers the liabilities of policyholders to their clients or customers. Regulatory: It covers the cost related to legal affairs, lawsuits and penalties due to a cyberattack.  

Other Questions
PLEASE HELP ME BRANLIEST FOR FIRST AND CORRECT ANSWERThere are 36 lines in the poem. The poem is numbered every 5 lines. ,end italics,,begin bold,A Saddle & the World,end bold, In Palestine, an old disheveled street,a wall of tiny shops, where grass grows between crumpled stone,I stand and watch in the shadow of the wall.Pots and tin pans and brooms and woven straw mats,even handmade saddles, spill into the narrow street.Heavy saddles, covered with burlap, to fit horses,mules, donkeys, sewn by someone who knows saddles.A woman in a ,begin italics,thobe,end italics,a long black dress,hand-embroidered with red cross-stitching on chest and sidespokes around the saddles.Bending down, she touches, pats, caresses,like a woman buying cloth.Finally she lifts her head, then do-si-dos,superscript,1,baseline,toward the bald man who owns the shopand asks the price of the saddle she likes best.But the price isn't set in stone and will change, like the weather,if you have some smarts at this haggling game.Like fencing,,superscript,2,baseline, you dance with agile steps around each other,touch with the point of your foil,,superscript,3,baseline, but never wound.He says, she says. Words fly, as conductor-handssweep the air for emphasis. The woman nods,and a corner of her mouth lifts. She fingers the coinsinside the slit in her belt."Sold! To the woman in embroidered dress!" the auctioneer would call outif she lived in Texas. Or Oklahoma. Or even New York.But in Palestine where she lives, a thousand women in embroidereddresseswould stand to claim the prize.I, in the uniform of my faded American jeans,ask the woman a foolish question,"How will you take this saddle home?"The woman's face cracks open, a smile spills out.Squatting, she picks up the saddle, an Olympian heavyweight champion,she hoists the saddle in the air, then lowers it onto her head.She stands tall, this Palestinian Yoga-woman, her head not merely holdinga saddle,But the world.("A Saddle & the World" by May Mansoor Munn. Copyright 1998 by May Mansoor Munn. Used by permission of the author.),begin bold,,superscript,1,baseline,do-si-do ,end bold,a circular dance move in which partners pass each other back-to-back,begin bold,,superscript,2,baseline,fencing ,end bold, the art of using a small sword (foil) to practice self-defense and offensive movements with an opponent,begin bold,,superscript,3,baseline,foil ,end bold, a small, light sword with a blunt edge and tip (used in fencing) The diameter of a circle is 6 kilometers. What is the area?d=6 kmGive the exact answer in simplest form.square kilometers workers day meaning history which issues are currently related to the arab-israeli conflict a) The settlement of the west bank b) the Israeli blockade on the Gaza Strip c) Control of the Sinai peninsula d) Control of Egypt e) disputed items in the Egypt Israel peace treaty The Judicial Branch has the power toSelect one:impeach and remove the president from officeoverride a congressional vetodeclare laws unconstitutionalapprove treaties with foreign nations Carla wants to save $55.50 to buy a new video game. Carla babysits her niece once a week and earns the same amount of money each week. After every time she babysits she donates $2 from the money she earned to the local food bank. Carla calculates that it will take her 6 weeks to save enough to buy her video game. Write and solve an equation to determine how much money Carla earns per week. Which of the following best describes a situation where an oligopoly exists?O A. A small number of producers command nearly the entire marketfor a certain good or service.B. A single producer is the only one selling a good or service with noclose substitutes.C. Many producers are selling slightly differentiated products thatare close substitutes of each other.D. A large number of businesses are selling identical products to awell-informed customer base. what is the poem Caged Bird about? The answer to this question if Eli Whitney knew creating the cotton gin would increase slavery in the united states do you think he would still have created it? Please help. Promise its quick. Which pair of words gives the best example of a slant rhyme?A. Lurch, pitchB. Pour, moreC. Let, lushD. Brisk, tomb The government wants to set new regulations that prohibit chlorofluorocarbons (CFCs) use in aerosol sprays and refrigerants. How will this act help with the sustainability of our environment? What is the answer to this question? .50 ml of a solution are diluted to a volume of 100 ml. The concentration of the dilutedsolution is 2 M. What was the concentration of the original solution?pls answer asap! will mark as brainly ist!! Which trade networks connected to the Byzantine Empire? Time for a change essay 300 words Part AWhat is the author's main purpose in "Our Beautiful Macaws andWhy They Need Enrichment"?Ato describe the different tasks zookeepers are required toperformBto explain why some pet macaws eventually live in zoosCto explain how a zoo is providing a stimulating environment for macaws Dto describe why zookeepers include specific equipment innew exhibits A 10 kg box initially at rest is pulled with a 50 N horizontal force for 4 m across a level surface. The force of frictionacting on the box is a constant 20 N. How much work is done by the gravitational force?A. 03OB. 10 JC. 100D. 50 J In response to a decrease in tissue metabolic activity, tissue oxygen concentrations ________, which causes a(n) ________. In response to a decrease in tissue metabolic activity, tissue oxygen concentrations ________, which causes a(n) ________. increase : active hyperemic response decrease : dilation of the arterioles decrease : increase in tissue ischemia decrease : active hyperemic response increase : constriction of the arterioles Max is mixing oil and gas for his moped. He uses 3.75 liters of gas and 1.5 liters of oil. How many liters of gas are used per liter of oil?