Help with Java coursework

R2DJ

Well-Known Member
Member
Joined
Jan 30, 2008
Messages
1,898
Trophies
0
Location
London
XP
795
Country
I am stuck with my Java coursework. Help please! :) This is what I have to do:

"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 ------****

--- denote spaces
20 students in total

What I have to do is to make a program in Java following the instructions mentioned above. Whenever I add a grade, a star must be added to the corresponding group. The same 4 categories will be used.

I know what to do mostly in this (use while loops, if-else statements, printing a star for each category) but I am stuck with how to display the histogram at the end (when the user enters 100+, the program stops and then the result histogram is shown.

Thanks :)
 

purplesludge

anyone have any ideas for this space
Member
Joined
Mar 2, 2009
Messages
1,047
Trophies
0
Age
31
Location
wv
Website
Visit site
XP
230
Country
United States
This is assuming the middle of your post is the histogram.
System.out.p rintln("0 - 29"+ spaces + low);
low being the variable holding the stars
To increase the stars in low
low = low.concat("*");
low needs to be initialized when created though
the weird spacing is because I can't use words longer than 26 characters
Edit:Added the word spaces to the println
 
General chit-chat
Help Users
    kenenthk @ kenenthk: Wear a cup