java//
Statistical Analysis of student grades.
1) Create an array of double of size 20
2) Ask user to enter 20 grades
example
Enter 1st student's grade: 85.88
... Enter 20th student's grade: 95.20 <enter> You are free to choose the grades. 3) Print the average and standard deviation of the grades for example average: 68.47 stdev: 19.45 4) Assign letter grades to the students. top %10 will get A (two people in this case) next %20 will get B (3rd, 4th, 5th, 6th people will get B) next %40 will get
so what problem do you have?
to write this simple program .
well what have you done till now? have you thought how you should start? I'd say start thinking of a pseudocode. :)
almost finnish but the sted is not working /public static void main(String[] args) throws Exception { Scanner in=new Scanner (System.in); System.out.println("input the number of students"); int arr=in.nextInt(); //if in case Students number less than 20 while (fix==false);{ fix=true; fix=true; boolean fix=false; double[] grades=new double [arr]; int i; double sum=0.0; double v=0.0; for( i=0;i<grades.length;i++){ System.out.println("input the grade of Student "+i+1); grades[i]=in.nextDouble(); sum=sum+grades[i]; } System.out.println("the total is "+sum); double average=sum/arr; System.out.println("the Average is "+average); for ( i=1; i<grades.length;i++){ v =v+(grades[i] - average) * (grades[i] - average); System .out.print("the grades are "+grades[i]); } double std =Math.sqrt((1/arr-1)*v); System.out.println("the std is "+std); } }
could you use a paste site like pastebin.com to paste your code? it is much more readable like that.
sorry that site is forbidden to access here in turkey and I am using the university server so I don't want to trouble with them . I think I've finish it . I found a way to calculate the standard deviation. even though its not the easiest way maybe but still work thank you
oh well if u get more problems message me :) and gj if you made it work!
thanks
@MicroBot help me I still didn't find a way to print the letters to each student for this conditions 4) Assign letter grades to the students. top %10 will get A (two people in this case) next %20 will get B (3rd, 4th, 5th, 6th people will get B) next %40 will get C (7th, 8th, 9th, 10th, 11th, 12th, 13th, 14th will get C) next %20 will get D (15th, 16th, 17th, 18th people will get B) next %10 will get F (19th, 20th people will get B) 5) print the letter grades 1st student's letter grade is A 2nd student's letter is C 3rd student's letter grade B ....
well I dont know what you have done untill now ...but my thoughts are: * you have 20 students in an array * you should sort that array from max grade to minimum *and then see how many students are 10% of 20 students and assign to those x students A grades. * then see how many are 20% and assign to the next y students in the array , B grade. * continue to the end... hope this helps
yeh exactely that's what I have to do but how to order the array "with the students numbers "
try using the sort method of arrays. http://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html
really I don't understand that would you write the way n codes plz .
Arrays.sort(double[] yourArray); this will sort yourArray into ascending order though...so you will have to copy your array backwards after the sorting.
btw i am not a java expert so i might even give you a false advice or not the optimal so it would be nice if someone else would confirm or give a look at this :)
well thanks
Join our real-time social learning platform and learn together with your friends!