Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Give the code for Part 1 and 2 (combined). The Prog07 AnalyzeGrades Program You wil extend the Prog07 AnelyzeGrades project that you developed for Program
Give the code for Part 1 and 2 (combined).
The Prog07 AnalyzeGrades Program You wil extend the Prog07 AnelyzeGrades project that you developed for Program 7, part 1 Step 1: Input Data [Completed in Part 1 You will use the File Dialog box lbrary (JFSleChooser) to allow the user to browse to a place on the computer and select the input tile (euse the showopenDialog method to display the dialog bex and use the getSelectedFsle nethod to retrieve the user's selection in the form of a File object). An example use of the JFileChooser ibrary can be found on pages 335-336 of your textbook. Note that you wll need the following import to use the IFileChooser ibrary inport javax.swing 3F11eChooser; The first ine of the input file wil include the number of grades to be analyzed (Le, the number of remaining lines to process), Beginning with ine 2, the input file will contain one grade per line You wil need to read in the grades and store them in an array for analyzing Step 2: Sorting the array [Completed in Part 1 You will need to sort the array for analysis. You will implement a BubbleSort method that uses the short dircuit approach to sorting an intger aay. The method will also take a string parameter that specfies whether the sort should be ascending c) or descending (desc"). You will also implement a Swap method that is called by the BubbleSort method to swap elements of an integer aray. Step 3: Conducting analyss You will need to analyze the contents of the sorted array to make the following calculations Minimum (e, lowest grade) 2. Maximum (Le, highest grade 3. Mean (Le, average 4. Median a. The median is the value that fals at the middle of the sorted set of values. b. If there is an odd number of the set of values, the median is the middle element [e. there are the same number of values above and below the median value For example, the median of (2,6,10,11,65 is 10.0 c IF there is an even number of the set ot values, the center two values are averagad to calculate the median L For example, the median of [2,6,10, 11, 65, 951 s 105 5. Count of letter grades a. Number of As: grades 90.0or higher b. Number of Bs: grades 80.0 or higher and less than 90.0 c Number of Cs: grades 70.0 or higher and less than 80.0 d. Number of Ds grades 600 or higher, and less than 70.0 e. Number of Fs: grades less than 60.0 Step 4: Printing analysis results You will use the File Dialog box lbrary (FsleChooser) to allow the user to browse to a place on the computer and select the output file(Le,use the shouSaveDialog nethod to display the dialog bex, use the Retselectedfile nethod to retrieve the user's selection in the forn of Fsle object, and use the File getPath) nethed to specify the filenane selected by the user). You will print the following information to the file specified by the user Sorted (descending) list of grades, one per line. After leaving a couple of blank lines, you will output the following, formatted to print 3 places past the Maimum: Number of As Number of Bs: Number ot Cs Number of Ds Number ot Fs Total Number of Grades Step 5: Binary Search After the output to the file has been generated, you wll promps the user to search for a particular grade in the array, 0 or more times. If the value is not found in the array, the BinarySearch method, should return a value of O. You should give the user feedback on either the locarion of the value in the array or message that the value is not found in the array. f the value is found more than once in the array, any position in which the value is found is fine. For example: Hould you like to seareh o a grade Enter grade: 56 Grade 56 is found at position 34 The Prog07 AnalyzeGrades Program You wil extend the Prog07 AnelyzeGrades project that you developed for Program 7, part 1 Step 1: Input Data [Completed in Part 1 You will use the File Dialog box lbrary (JFSleChooser) to allow the user to browse to a place on the computer and select the input tile (euse the showopenDialog method to display the dialog bex and use the getSelectedFsle nethod to retrieve the user's selection in the form of a File object). An example use of the JFileChooser ibrary can be found on pages 335-336 of your textbook. Note that you wll need the following import to use the IFileChooser ibrary inport javax.swing 3F11eChooser; The first ine of the input file wil include the number of grades to be analyzed (Le, the number of remaining lines to process), Beginning with ine 2, the input file will contain one grade per line You wil need to read in the grades and store them in an array for analyzing Step 2: Sorting the array [Completed in Part 1 You will need to sort the array for analysis. You will implement a BubbleSort method that uses the short dircuit approach to sorting an intger aay. The method will also take a string parameter that specfies whether the sort should be ascending c) or descending (desc"). You will also implement a Swap method that is called by the BubbleSort method to swap elements of an integer aray. Step 3: Conducting analyss You will need to analyze the contents of the sorted array to make the following calculations Minimum (e, lowest grade) 2. Maximum (Le, highest grade 3. Mean (Le, average 4. Median a. The median is the value that fals at the middle of the sorted set of values. b. If there is an odd number of the set of values, the median is the middle element [e. there are the same number of values above and below the median value For example, the median of (2,6,10,11,65 is 10.0 c IF there is an even number of the set ot values, the center two values are averagad to calculate the median L For example, the median of [2,6,10, 11, 65, 951 s 105 5. Count of letter grades a. Number of As: grades 90.0or higher b. Number of Bs: grades 80.0 or higher and less than 90.0 c Number of Cs: grades 70.0 or higher and less than 80.0 d. Number of Ds grades 600 or higher, and less than 70.0 e. Number of Fs: grades less than 60.0 Step 4: Printing analysis results You will use the File Dialog box lbrary (FsleChooser) to allow the user to browse to a place on the computer and select the output file(Le,use the shouSaveDialog nethod to display the dialog bex, use the Retselectedfile nethod to retrieve the user's selection in the forn of Fsle object, and use the File getPath) nethed to specify the filenane selected by the user). You will print the following information to the file specified by the user Sorted (descending) list of grades, one per line. After leaving a couple of blank lines, you will output the following, formatted to print 3 places past the Maimum: Number of As Number of Bs: Number ot Cs Number of Ds Number ot Fs Total Number of Grades Step 5: Binary Search After the output to the file has been generated, you wll promps the user to search for a particular grade in the array, 0 or more times. If the value is not found in the array, the BinarySearch method, should return a value of O. You should give the user feedback on either the locarion of the value in the array or message that the value is not found in the array. f the value is found more than once in the array, any position in which the value is found is fine. For example: Hould you like to seareh o a grade Enter grade: 56 Grade 56 is found at position 34Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started