Part 1: Searching and sorting an int array Instructions: Write a program called RandomGrades.java that generates...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Part 1: Searching and sorting an int array Instructions: Write a program called RandomGrades.java that generates integers representing student grades, sorts the list in descending order, and searches for a specific grade or grade range as indicated by the user. 1. Begin by continuously prompting the user to enter an integer representing the number of students enrolled in CSE7 (between 5 and 150). a. Check that the user only entered an int, and print an error message if the user enters anything other than an int. b. Print a different message for an int that is out of the range from 5-150. 2. Using the integer input from the user as the length (#1 above), declare/create an array of random integer values ranging from 0-100. a. Note: it doesn't matter how you generate these numbers (i.e. using Math.random() or a Random object) 3. Print the unsorted, original array with elements on the same line(s) (not a single element per line) 4. Next, sort the array into descending order using the sorting algorithm of your choice. a. You must include a comment within your code describing which algorithm you chose and why. 5. Print the sorted array, as well as the average course grade (to 3 decimal places). 6. Prompt the user to enter either an integer representing a specific score to search for in the list, or a character representing a letter grade range. a. If the user enters an integer, use binary search to find the entered grade. Indicate if the grade was found or not, and print out the number of iterations used. i. Make sure the grade entered is within the valid grade range (0-100) b. If the user enters A, B, C, D, F: display the number of occurrences of scores in the specified grade letter range. i. ii. If the user types 'A', you should return the number of exam scores from the class that are within the A range (identified below). For example, assume that: 1. Scores between 90 and 100 represent As 2. Scores between 80 and 89 represent Bs 3. Scores between 70 and 79 represent Cs 4. Scores between 60 and 69 represent Ds 5. Scores between 0 and 59 represent Fs. c. If the user types anything else, reprompt them for valid input (either an int between 0 and 100 or chars A, B, C, D, F). Sample output: Enter the class size: 15 Final grades for CSE7: 90 100 54 89 77 70 94 93 72 61 80 86 82 93 74 Descending CSE7 Grades: 100 94 93 93 90 89 86 82 80 77 74 72 70 61 54 Average course grade: 81.000 Enter a grade/grade range to search for: k Invalid option, try again. Enter a grade/grade range to search for: 81 81 was not found in the list with 4 Alternate run: Enter the class size: 5 iterations Final grades for CSE7: 90 59 54 89 77 Descending CSE7 Grades: 90 89 77 59 54 Average course grade: 73.800 Enter a grade/grade range to search for: F There are 2 grades in the F range. Part 1: Searching and sorting an int array Instructions: Write a program called RandomGrades.java that generates integers representing student grades, sorts the list in descending order, and searches for a specific grade or grade range as indicated by the user. 1. Begin by continuously prompting the user to enter an integer representing the number of students enrolled in CSE7 (between 5 and 150). a. Check that the user only entered an int, and print an error message if the user enters anything other than an int. b. Print a different message for an int that is out of the range from 5-150. 2. Using the integer input from the user as the length (#1 above), declare/create an array of random integer values ranging from 0-100. a. Note: it doesn't matter how you generate these numbers (i.e. using Math.random() or a Random object) 3. Print the unsorted, original array with elements on the same line(s) (not a single element per line) 4. Next, sort the array into descending order using the sorting algorithm of your choice. a. You must include a comment within your code describing which algorithm you chose and why. 5. Print the sorted array, as well as the average course grade (to 3 decimal places). 6. Prompt the user to enter either an integer representing a specific score to search for in the list, or a character representing a letter grade range. a. If the user enters an integer, use binary search to find the entered grade. Indicate if the grade was found or not, and print out the number of iterations used. i. Make sure the grade entered is within the valid grade range (0-100) b. If the user enters A, B, C, D, F: display the number of occurrences of scores in the specified grade letter range. i. ii. If the user types 'A', you should return the number of exam scores from the class that are within the A range (identified below). For example, assume that: 1. Scores between 90 and 100 represent As 2. Scores between 80 and 89 represent Bs 3. Scores between 70 and 79 represent Cs 4. Scores between 60 and 69 represent Ds 5. Scores between 0 and 59 represent Fs. c. If the user types anything else, reprompt them for valid input (either an int between 0 and 100 or chars A, B, C, D, F). Sample output: Enter the class size: 15 Final grades for CSE7: 90 100 54 89 77 70 94 93 72 61 80 86 82 93 74 Descending CSE7 Grades: 100 94 93 93 90 89 86 82 80 77 74 72 70 61 54 Average course grade: 81.000 Enter a grade/grade range to search for: k Invalid option, try again. Enter a grade/grade range to search for: 81 81 was not found in the list with 4 Alternate run: Enter the class size: 5 iterations Final grades for CSE7: 90 59 54 89 77 Descending CSE7 Grades: 90 89 77 59 54 Average course grade: 73.800 Enter a grade/grade range to search for: F There are 2 grades in the F range.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
One persons reform in some cases may be considered an attack on another persons vital interests. Describe how the antebellum reform movementsparticularly temperance, colonization, and womens...
-
UBS AG is a global provider of financial services to private, corporate and institutional clients. The companys financial businesses are organized on a worldwide basis into three business divisions...
-
The number of automobile accidents reported per month helps to identify intersections that require improvement. The number of crashes per month reported at an intersection near a university campus in...
-
What are bride service, bridewealth, and dowry?
-
Rainoy, Inc., was organized on June 5, 2012. It was authorized to issue 400,000 shares of $10 par common stock and 50,000 shares of 4 percent cumulative class A preferred stock. The class A stock had...
-
A shaft simply supported by a truncated conical pivot bearing that carries an axial load at its center and the cone angle is 120. The axial load on the bearings is 3kN. The shaft speed is 1440 rpm...
-
1. Use Solver to create a Sensitivity Report for, and answer the following questions: a. Is the solution degenerate? b. Is the solution unique? c. Explain the signs of the reduced costs for each of...
-
1. *For following circuit where C = C = 100 uF, R = R = 2000. ww R x(1) R a) Find its transfer function H(s). b) Find its poles. c) Find its unit impulse response h(t). C y(t)
-
Assume a Centaur V upper stage with an empty mass of 2,247 kg, diameter of 3.05 meters and height of 12.68m, the wall thickness is 41mm, whereas the motor can be assumed to fill up 1/4 of the inner...
-
For pressure-driven laminar flow between two horizontal infinite parallel plates separated by a distance 2h, the velocity components are: a) where U is the centreline velocity and the x-axis is...
-
Discuss how geometry, surface condition and material quality can have; a) A significant influence on the fatigue life of a cyclically stressed component. (5 marks) b) Explain the differences between...
-
Laura dives with a watch around her arm. Her watch can withstand an absolute pressure of P = 5.5 bar? Assume a gravity acceleration of g = 9.81 m/s, and a density of water pw = 1002 kg/m. Hint: 1 bar...
-
Write a paper on Competitive Advantage in the Global Economy
-
Below is a sample of the data in the file NFLAttendance which contains the 32 teams in the National Football League, their conference affiliation, their division, and their average home attendance....
-
What is meant by liquidity and why might a supplier want to assess the liquidity position of one of their customer companies?
-
Describe the working capital cycle and calculate the length of this for a company of your choice.
-
Discuss THREE possible reasons why an entitys gross profit margin might increase from one year to the next.
Study smarter with the SolutionInn App