Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Computer Science FRQ Practice Question. Thank you to whoever is going to help. Three static methods will be used in this problem. This program is
Computer Science FRQ Practice Question. Thank you to whoever is going to help.
Three static methods will be used in this problem. This program is supposed to resemble giving tests a bell curve. public class Stats{ public static double mean( double[] data ) {//...to be solved in part a...} public static double stdDev( double[] data) {//...to be solved in part b...} public static Stringl grades( double[] scores) {/I...to be solved in part c...} a) Write the method mean which calculates and returns the mean or average of an array of type double named data. To calculate the mean, find the sum of the values in data and divide by the number of values in data. For example, if data contains {9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9,4} The call Stats.mean(data) should return 7.0. public static double mean(double[] data){ b) Write the method stdDev which calculates and returns the standard deviation of an array of type double named data. Regardless of your answer for part a, you may assume that the method mean works properly and must call it in your solution for full points. To calculate the standard deviation: 1. Calculate the mean of the data. 2. Then for each number: subtract the mean and square the result. Store each of these results in a new array. 3. Then calculate the mean of those squared differences in the array from #2. 4. Take the square root of #3 and that is the standard deviation. {9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4} The call Stats.stdDev(data) should return 2.9832867780352594 public static double stdDev(double[] data) c) Write the method grades which calculates and returns an array of Strings representing the grades corresponding to an array of doubles representing student scores named scores. Regardless of your answer for parts a and b, you may assume that the methods mean and stdDev work properly and must call them in your solution for full points. Grades are calculated and awarded as follows: If the corresponding score in scores is greater than or equal to the mean plus two standard deviations, the student gets an A. Otherwise, if the corresponding score in scores is greater than or equal to the mean plus one standard deviation, the student gets a B. Otherwise, if the corresponding score in scores is greater than or equal to the mean, the student gets a C. Otherwise, if the corresponding score in scores is greater than or equal to the mean minus one standard deviation, the student gets a D. Otherwise, the student gets an E. 1 Below is an array scores and the corresponding values in the returned array. scores 9 2 5 4 12 78 11 9 3 7 4 12 5 4 10 9 6 9 4 returned CEDEB CCB CECEB DEB CDCE array For example, a 12 receives a score of B because the mean for the scores array is 7, the standard deviation is 2.983... and 12 is greater than or equal to the mean plus one standard deviation (9.983...) but not quite two standard deviations above the mean (12.966...). public static String() grades ( double[] scores ) {
Step 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