0

how can i get this program, to tally the number of grades above 90 , between 80 and 89 and etc
import java.util.*;
public class grades

{import java.util.*;
public class grades
{
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in); 
    int i, n;
        double sum= 0, score=0 
    double avg
        System.out.println(" enter the number of students");
    n=input.nextInt();
        for(i=1; i<=n; i++){
        System.out.print("enter an Exam score");
        score= input.nextInt();
        sum= sum + score;}
    avg=(double) sum / n;
    System.out.println("Average is: " + avg);
    }
    }


public static void main(String[] args)
{
Scanner input = new Scanner(System.in); 
int i, n;
    double sum= 0, score=0 
double avg
    System.out.println(" enter the number of students");
n=input.nextInt();
    for(i=1; i<=n; i++){
    System.out.print("enter an Exam score");
    score= input.nextInt();
    sum= sum + score;}
avg=(double) sum / n;
System.out.println("Average is: " + avg);

i just dont know how to set it up..

2
Contributors
2
Replies
6
Views
2 Years
Discussion Span
Last Post by jstfsklh211
0

ignore the second copy code it added a secondary copy on here the code is just

import java.util.*;
public class grades
{
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in); 
    int i, n;
        double sum= 0, score=0 
    double avg
        System.out.println(" enter the number of students");
    n=input.nextInt();
        for(i=1; i<=n; i++){
        System.out.print("enter an Exam score");
        score= input.nextInt();
        sum= sum + score;}
    avg=(double) sum / n;
    System.out.println("Average is: " + avg);
    }
    }
0

create an array and in your loop do something like

array[int(score/10)]++;

not sure what the exact sytanx is as i dont work with java

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.