This is my last resort i have had sleepless nights trying to create this code but have had no luck please can someone help me i need to create a piece of code that fit the requirements below


The University wants to make a basic graphical display to show how many people received different grades for a piece of work on a module. You are required to write a program in Java that achieves this.

The program is in a number of parts.

The program should allow the tutor to enter in the various marks which the 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 *** (3 students received a mark between 0-29)
30-39 *****
40-69 ********
70-100 ****

20 students in total

As the tutor enters each mark, a counter should count the number of student’s marks which have been entered.

You are a bit late at doing this assignment arn't you! The other person asked about this homework 26 days ago, at least he attempted to write it first.

I have tried thats the whole point of me coming here its because i actually cant get a functioning program im not oen to look for handouts ive been trying for near half a month now im just in a desperate position right now as i have no options left can someone please help me

public static void main(String[] args) {

            public static void main(String[] args) {

        final int SENTINAL = -1;
        int anumber;

        Scanner in = new Scanner( System.in );

        //Read in first number
        System.out.print("Enter an integer, or 101 to stop : ");
        anumber = in.nextInt()

this is the actual part of my code that im 100% sure is going to work because that the only i code i can write properly i know its a lot to ask but please i am desperate i don't want to fail my module and i solemly swear ill never come with another programming problem again

Edited 3 Years Ago by mike_2000_17: Fixed formatting

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int[] rangeCounts = new int[4];
        String[] rangeDisplays = new String[4];
        rangeDisplays[0] = " 0-29 ";
        rangeDisplays[1] = "30-39 ";
        rangeDisplays[2] = "40-69 ";
        rangeDisplays[3] = "70-100 ";
        int lastInput = 0;
        Scanner inputScanner = new Scanner(System.in);

        while (lastInput <= 100) {
            System.out.println("Input Grade.");
            lastInput = Integer.parseInt(inputScanner.nextLine()



            if (lastInput >= 0 && lastInput < 30) {
                rangeCounts[0]++;
            } else if (lastInput >= 30 && lastInput < 40) {
                rangeCounts[1]++;
            } else if (lastInput >= 40 && lastInput < 70) {
                rangeCounts[2]++;
            } else if (lastInput >= 70 && lastInput <= 100) {
                rangeCounts[3]++;
            }
        }

        for (int rangeI = 0; rangeI < rangeCounts.length; rangeI++) {

            for (int i = 0; i < rangeCounts[rangeI]; i++) {
                rangeDisplays[rangeI] += '*';
            }
        }

        for (int i = 0; i < rangeDisplays.length; i++) {
            System.out.println(rangeDisplays[i])

        }
    }
}

Try this one, i've already saw there are some solutions that might work, hope this might help you! Cheers!

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

hi mikrotik thanks for the code segment i really appriciate it i ran it with net beans and quite a few errors came up it wouldn't run properly i tried tweaking it but its still not running thanks for the segment though i will try a bit more to make it work cheers

This article has been dead for over six months. Start a new discussion instead.