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..

Recommended Answers

All 2 Replies

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);
    }
    }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.