
Write a program that should allow a tutor to enter in various marks which students have been awarded, until the tutor enters in a mark exceeding 100. At this point the program should display a histogram. Each star represents a student who achieved a module mark in the range shown.
0-29 *
30-39 *
40-69 **
70-100 **
20 students in total.
Your program should work with any number of student marks entered.
After the histogram, a variety of statistics should be displayed (e.g. average mark awarded, number of students passing, highest mark, and lowest mark)

The answer for the above question as i did is as follows
import java.util.*;
class ClassStatistics
{
public static void main(String args[])
{
float marks[]=new float[20];
int i,ctr=0,ctr1=0,ctr2=0,ctr3=0,passed=0;
float highest=0, lowest;
Scanner input=new Scanner(System.in);
for(i=0;i<20;i++)
{
System.out.println("Enter the marks of student");
System.out.println("Enter a mark greater than 100 to view results");
marks[i]=input.nextFloat();
if(marks[i]>=0&&marks[i]<=29)
ctr++;
else if(marks[i]>=30&&marks[i]<=39)
ctr1++;
else if(marks[i]>=40&&marks[i]<=69)
ctr2++;
else if(marks[i]>=70&&marks[i]<=100)
ctr3++;
if(marks[i]>100)
break;
if(marks[i]>=50)
passed++;
if(marks[i]>=highest)
highest=marks[i];
}
System.out.print("0-29 ");
while(ctr!=0)
{
System.out.print("*");
ctr--;
}
System.out.println("");
System.out.print("30-39 ");
while(ctr1!=0)
{
System.out.print("*");
ctr1--;
}
System.out.print("");
System.out.print("40-69 ");
while(ctr2!=0)
{
System.out.print("*");
ctr2--;
}
System.out.print("");
System.out.print("70-100 ");
while(ctr3!=0)
{
System.out.print("*");
ctr3--;
}
int j=0;
lowest=marks[j];
j++;
while(j<20)
{
if(marks[j]<=lowest)
lowest=marks[j];
j++;
}
System.out.println("Number of students passing "+passed);
System.out.println("Highest mark "+highest);
System.out.println("Lowest mark "+lowest);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.