Write a Java code that read 8 positive integers from the user and store them in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java code that read 8 positive integers from the user and store them in an array. The program should ensure that the numbers of the array are positive. If not, the program will keep asking user to enter positive values. Then, it finds the position (or index) of the maximum and minimum values in the array, and swap them (move the max element to the position of the min, and move the min element to the position of the max). Then it calculates the median of the elements of this array (for this step an ascending order sort should be done before calculating the median). Then run the code again for integer array of size 7. Loop and conditionals should be used otherwise marks will be deducted. Don't hardcode the output otherwise marks will be deducted. Write a Java code that read 8 positive integers from the user and store them in an array. The program should ensure that the numbers of the array are positive. If not, the program will keep asking user to enter positive values. Then, it finds the position (or index) of the maximum and minimum values in the array, and swap them (move the max element to the position of the min, and move the min element to the position of the max). Then it calculates the median of the elements of this array (for this step an ascending order sort should be done before calculating the median). Then run the code again for integer array of size 7. Loop and conditionals should be used otherwise marks will be deducted. Don't hardcode the output otherwise marks will be deducted.
Expert Answer:
Answer rating: 100% (QA)
import javautilArrays import javautilScanner public class MaxMinMedian public static void ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
For each of the following exercises, write the Java code statements to perform the action(s) requested. Submit your code statements and a capture of your outputs for each exercise. 1. Take 5 integers...
-
Let F(z, y) = 7(z + y) i + 5 sin(y) j. Find the tine integral of F around the perimeler of the rectangie with comers (4,0). (4,2). (-1,2). (-1,0). traversed in that order.
-
A sample containing an alkali sulfate is dried, weighed and dissolved in dilute HCl. Barium chloride solution is added in excess to precipitate barium sulfate, and the precipitate is digested in the...
-
? Fisheries Bhd is a small listed company involves in fishing and selling fish to the public via retail outlets. The company owns a building that was acquired in early September 2014 for RM1,200,000,...
-
Stober Corporation made two purchases of inventory on account during the month of March. The first purchase was made on March 5 for $30,000, and the second purchase was made on March 10 for $60,000....
-
How has the multinational enterprise evolved? How have the changes in MNEs affected IHRM?
-
On February 11, 2009, plaintiff Levista, Inc. (plaintiff) filed against defendant Ranbaxy Pharmaceuticals, Inc. (defendant), pursuant to this Courts diversity jurisdiction under 28 U.S.C. 1332(a),...
-
Bill Binder's business nearly went under when Colorado almost passed the bottle bill. Binder's Beverage produced soft drinks for many of the large grocery stores in the area. After the bottle bill...
-
Explain entity integrity and referential integrity rules in relational model. Show how these are realized in SQL.
-
The whistleblowing aspects of this case were first discussed in the text. What follows is a more comprehensive discussion of accounting and auditing issues. In 2005, Tony Menendez, a former Ernst &...
-
On January 1, 2017, Virginia Co. acquired a 5-year bond with a total face value of P5,000,000 for P5,379,079. The bonds carry an interest of 12% per year payable every December 31. The bonds are to...
-
Describe the records you kept of the services provided, decisions made and follow up actions for each person co-existing mental health and AOD issues you worked with. Include any de-identified...
-
(4) Solve the initial value problem: 3 xy' +2y=3x, y(1) = -2. Linear, order one: y = x + cr 3 IVP: C = - 11/3 y = n
-
Solve the inequality. 17x+8 2(x - 1)
-
The Plan Risk Responses process can utilize a cost-benefit analysis Question 5 options: True False
-
Find the domain of the following function. Give your answer in interval notation. f(x)=-2x+18
-
In Exercises 10-12, you are given a differential equation. The corresponding slope field has also been drawn. Sketch enough solution curves in the slope field to be able to describe the behavior of...
-
Subprime loans have higher loss rates than many other types of loans. Explain why lenders offer subprime loans. Describe the characteristics of the typical borrower in a subprime consumer loan.
-
Expand each of the following acronyms: a) W3C b) OOP c) CLR d) MSIL e) UML f) IDE
-
State whether each of the following is true or false. If false, explain why. a) You cannot instantiate objects of type Stream. b) Typically, a sequential file stores records in order by the...
-
Identify and correct the errors in each of the following sets of code: a) while (c
-
You are studying survival times for mice given a drug at one of three doses (Low, Medium, or High). You define two dummy variables: (a) With these definitions, write the expressions for the mean...
-
The data in Table 8.25 were collected in order to study factors affecting the supply and demand for commercial air travel. Data on various aspects of commercial air travel for an arbitrarily chosen...
-
It is beneficial to be able to estimate the yield of useful product of a tree based on measurements of the tree taken before it is harvested. Measurements on four such variables were taken on a...
Study smarter with the SolutionInn App