Part 3 Use Eclipse to write a Java program that does the fol

Part 3: Use Eclipse to write a Java program that does the following. Name your program labljava 1. It should read integer grades from the user until the user enters the sentinel -1. As you read the grades, count them, and store them in an integer array. Assume cach grade entered is an integer in the range 0..100 and that there will be at most 100 grades entered. Hence, declare an int array named grades of size 100 2. After all the grades have been counted and entered in the array grades, do the following: (1) output the number of grades entered; (2) compute and output the mean of the grades in the array (recall that the mean is the sum of the grades divided by the number of the grades: G) compute and output the standard deviation of the grades in the array. Use the following formula to compute the standard deviation Standard deviation im0 mean where Nis the number of grades and mean is the mean of the grades Both mean and standard deviations should be floating point values. Your sample dialog with the user may like the following Please enter the grades (-1 indicates the end of input) 70 80 60 90 -1 Total number of grades is 4 The mean is 75.00 The standard deviation is 11.180339887498949

Solution

import java.util.*;
import java.lang.*;
import java.io.*;


class Marks
{
   public static void main (String[] args) throws java.lang.Exception
   {
       double[] marks = new double[100];
       int i = 0;
       System.out.println(\"Please enter the grades (-1 indicates the end of input)\");
       while(true)
       {
           Scanner input = new Scanner(System.in);
           double temp;
           temp = input.nextDouble();
           if (temp == -1)
           {
               break;
           }
           else
           {
               marks[i++] = temp;
              
           }
      
       }
       System.out.println(\"Total number of grades is: \");
       System.out.println(marks.length);
       double sum = 0;
       for (int j = 0;j < marks.length; j++)
       {
           sum += marks[j];
       }
       double mean = sum / marks.length, deviation = 0;
       for (int j = 0;j < marks.length; j++)
       {
           deviation += ((mean - marks[j]) * (mean - marks[j]));
       }
      
       System.out.println(\"Mean: \");
       System.out.println(mean);
       System.out.println(\"Standard Deviation: \");
       System.out.println(Math.sqrt(deviation/marks.length));
   }
}

 Part 3: Use Eclipse to write a Java program that does the following. Name your program labljava 1. It should read integer grades from the user until the user e
 Part 3: Use Eclipse to write a Java program that does the following. Name your program labljava 1. It should read integer grades from the user until the user e

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site