3. Sorting Array Create a program that sort array of numbers in ascending or descending order....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. Sorting Array Create a program that sort array of numbers in ascending or descending order. The program should prompt the user to enter length of the array, then prompt the user to enter a list of numbers. The value that the user has entered in the length of the array will be the basis for the number of times the user will enter. For example, the user has entered 3 for the length of the array, the user again will be asked to enter 3 numbers. After the user enters a list of numbers, ask the user if it's going to sort the array in ascending or descending order. Then display the sorted number based from the user's choice. For example: Sorting 4 elements array in ascending order: run: Enter Array Length: 4 Enter Element Number 1: 3 Enter Element Number 2: 1 Enter Element Number 3: 10 Enter Element Number 4: 0 Sort Array in Ascending Order? [1 = yes, 0 = no]: 1 Sorted elements in Ascending Order: 0 1 3 10 BUILD SUCCESSFUL (total time: 23 seconds) 3. Sorting Array Create a program that sort array of numbers in ascending or descending order. The program should prompt the user to enter length of the array, then prompt the user to enter a list of numbers. The value that the user has entered in the length of the array will be the basis for the number of times the user will enter. For example, the user has entered 3 for the length of the array, the user again will be asked to enter 3 numbers. After the user enters a list of numbers, ask the user if it's going to sort the array in ascending or descending order. Then display the sorted number based from the user's choice. For example: Sorting 4 elements array in ascending order: run: Enter Array Length: 4 Enter Element Number 1: 3 Enter Element Number 2: 1 Enter Element Number 3: 10 Enter Element Number 4: 0 Sort Array in Ascending Order? [1 = yes, 0 = no]: 1 Sorted elements in Ascending Order: 0 1 3 10 BUILD SUCCESSFUL (total time: 23 seconds)
Expert Answer:
Answer rating: 100% (QA)
1 import javautilScanner class Main public static void main... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
Use java There are n gardens in a row. The gardens are numbered 1 to n and the i-th garden has a greenness of a[i], with higher numbers representing greener gardens. Let us define the "greenness on...
-
1. Please complete the following Java class which is an implementation of a buffer of integers. with instructions labelled a and b below the incomplete code. class IntBuff { int[] elements; // the...
-
Java Company earned net income of $85,000 during the year ended December 31, 2018. On December 15, Java declared the annual cash dividend on its 4% preferred stock (par value, $120,000) and a $0.25...
-
Chris Co. purchased a piece of equipment and incurred the following costs. Which of these costs is properly capitalized and recorded as part of the cost of the equipment? I. Freight charges to...
-
You have a choice between receiving (1) A $50,000 payment today, (2) A $7,500 annuity for the next 10 years and a lump-sum amount of $20,000 at the end of the10th year. If money is worth 10%, which...
-
Show that the power produced by a wind turbine is proportional to the cube of the wind velocity and to the square of the blade span diameter.
-
In 2004, Jui-Chen Lin, a citizen of China, entered into an agreement with Robert Chiu and Charles Cobb, citizens of the United States, to form an LLC to acquire and operate a fast-food restaurant in...
-
Daffitar Inc. produces and sells theater set designs and costumes. The company began operations on January 1, 2014. The following transactions relate to securities acquired by Daffitar Inc., which...
-
Why would you perform a silent installation? What is the purpose of a password complexity policy? Oracle offers a free download of all editions of the Oracle Database. How does the company derive...
-
According to an extensive survey conducted for Business Marketing by Leo J. Shapiro & Associates, 66% of all computer companies are going to spend more on marketing this year than in previous years....
-
In the world of not-for-profit fund raising there are activities that are legal and activities that are illegal. Likewise there are activities that are ethical and there are activities that are not...
-
Discuss the changes made to the crime of burglary through the years and why today, the penalties for burglary are so severe. Identify key elements consistent with computer trespass and computer...
-
What are the evolutionary dynamics shaping the emergence and persistence of antibiotic resistance in bacterial populations, and how can insights from microbial ecology inform strategies for combating...
-
Ponoroff is a life-long resident of Florida. He owns a home with a current value of $300,000, which is subject to a first mortgage lien of $345,000, and a second mortgage in the amount of $50,000....
-
Critically analyze the security mechanisms incorporated into contemporary operating systems, including access control policies, privilege escalation prevention, and memory protection mechanisms....
-
in Coca-Cola's footnotes, is common stock repurchased on the open market or privately negotiated? Explain
-
On January 1, 2024, HGC Camera Store adopted the dollar-value LIFO retail inventory method. Inventory transactions at both cost and retail, and cost indexes for 2024 and 2025 are as follows: 2024...
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree? What happens if you call VEB-TREE-DELETE with an element that is not in the vEB tree? Explain why the...
-
Suppose that we toss balls into b bins until some bin contains two balls. Each toss is independent, and each ball is equally likely to end up in any bin. What is the expected number of ball tosses?
-
A self-organizing list is a linked list of n elements, in which each element has a unique key. When we search for an element in the list, we are given a key, and we want to find an element with that...
-
Mexico has labor laws that specify a daily (rather than hourly) minimum wage. In 2018, the daily minimum wage in Mexico was about 103 pesos per day, and the exchange rate between Mexican pesos and...
-
In 2017, an estimated 7.7 million Mexican-born immigrants were employed in the United States. a. If 60 percent of the Mexican-born immigrants remitted money to family members in Mexico in 2017, and...
-
A mathematical approximation called the rule of 70 tells us how long it will take for something to double in size if it grows at a constant rate. The doubling time is approximately equal to the...
Study smarter with the SolutionInn App