Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    The University wants to make a 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. It should be a basic console application and not use Windows JFrame. The program is in a
    number of parts.
    1. 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.
    This is an example of the output. The example below shows the distribution of marks for 20 students.
    Your program should work with any number of student marks entered.
    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.
     Use the same 4 category ranges shown above.
     Make sure the display is neatly formatted as above.
     Your program should make use of ‘loops’ for the display of the stars for each category.
    Extras:
    2. After the histogram, a variety of statistics should be displayed (e.g. average mark awarded,
    number of students passing, highest mark, and lowest mark)
    3. The histogram shows each category horizontally across the screen. Copy your original
    solution and make changes to the copy to display the histogram vertically so the stars in a
    category should go downwards and not across the screen, e.g.:
    0-29 30-39 40-69 70-100
    * * * * (as it prints the line decide if each category needs a star or space)

    Below is my code but got stuck there as I don't know what to do next...

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package histogram;
    import java.util.Scanner;


    /**
    *
    * @author user
    */
    public class Histogram {


    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    int marks;
    int counter1 = 0, counter2 = 0, counter3 = 0, counter4 = 0;
    double average;

    Scanner readmarks = new Scanner(System.in);

    System.out.println ("Please Enter Your Marks");
    marks = readmarks.nextInt();


    while (marks <=100 && marks >=0){

    }
    if (marks <=29 && marks >=0){
    counter1 = counter1+1;
    System.out.println();

    }

    if (marks <=39 && marks >=30){
    counter2 = counter2+1;

    }

    if (marks <=69 && marks >=40){
    counter3 = counter3+1;

    }

    if (marks <=100 && marks >=70){
    counter4 = counter4+1;




    System.out.println("Please Enter Your Marks");
    marks = readmarks.nextInt();






    }
    }

    }
    Offline

    2
    ReputationRep:
    I dont know much java but the advice i would give you is to break down what you have to do into modules and write out pseudocode of how you will solve it. then implement. Good luck

    AA
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: December 2, 2014

University open days

  • University of Bradford
    All faculties Undergraduate
    Wed, 21 Nov '18
  • Buckinghamshire New University
    All Faculties Postgraduate
    Wed, 21 Nov '18
  • Heriot-Watt University
    All Schools Postgraduate
    Wed, 21 Nov '18
Poll
Black Friday: Yay or Nay?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.