Suggestions for my Java program (and need testers). (in Off-topic)


SNK3R May 2 2006 4:35 PM EDT

Okay, I just finished my last project for the semester last night and I was extremely disappointed in how short it was. So, I'd like to add some more things into the program, but I'm not sure what else I can do. I also need a few people to test the program to make sure I'm not getting any errors (checking my code wouldn't be a bad idea, too, if you're willing). So, I'd like suggestions on the program and my code. If you've read this much and you're interested, read below for instructions on how to get it working.

Instructions: If you have TextPad or any other editor, just download the .java file, compile it, then run it in there. If you don't, use the above instructions.

This is, of course, where the program begins. The following is what the program is supposed to do (and where I need people to check my code/program for durability):

Create a class that graphs a grade distribution (number of A's, B's, C's, D's, and F's) horizontally by printing lines with proportionate numbers of asterisks corresponding to the percentage of grades in each category. Write methods to set the number of each letter grade; read the number of each letter grade; return the total number of grades; return the percentage of each letter grade as a whole number between 0 and 100, inclusive; and draw the graph. Set it up so that 50 asterisks correspond to 100 percent (each one corresponds to 2 percent), include a scale on the horizontal axis indicating each 10 percent increment from 0 to 100 percent, and label each line with its letter grade. For example, if there are 1 A, 4 B's, 6 C's, 2 D's, and 1 F, the total number of grades is 14, the percentage of A's is 7, the percentage of B's is 29, the percentage of C's is 43, the percentage of D's is 14, and the percentage of F's is 7. The A row would contain 4 asterisks (7 percent of 50 rounded to the nearest integer), the B row 14, the C row 21, the D row 7, and the F row 4.

So, again, I'm open to suggestions in my code and looking for things to add, in addition to checking if my program is fully functional without run-time (shouldn't be) or logic errors. So, if you have some spare time or are bored, help me out. ;) Any help and/or suggestions will be very appreciated. If you need any help getting it to run or questions on my code, don't hesitate to ask by posting here or by Chatmail/PM.

private May 4 2006 3:45 AM EDT

You should change your for loops to
for (double i = 0.5; i <= percentX / 2.0; i++)

Replace X with A,B,C,D,F

Please test that before using it. Note that setting i to start as 0.4999 causes rounding (i.e. it will print out 1 asterisk for anything between 1% and 3%, including 1% but not including 3%, which prints two asterisks). Note: Although double comparisons are normally dangerous, 0.5 happens to be possible to store exactly. Otherwise, I'd be suggesting this:

for (double i = 0.499999; i <= percentX / 2.0; i++)



Your current code does the same thing...but your code longer for no reason. I didn't test my code nor did I test yours.

Another improvement you could make is, if the teacher is asking for submissions of both the source and the class file, to put the class file in a jar so it can be run by double-clicking it.

private May 4 2006 3:50 AM EDT

:::Looks up the scanner class:::

Wow, Java finally added a decent method of reading input. Didn't know the scanner class was added to 1.5 .


I used to find it easier to just make a swing interface than to use console i/o.

Hey, that's a good idea for an improvement! That would sharply increase the file size with no significant expenditure of effort (unless you don't know how to use swing, in which case it might be harder).

AdminQBnovice [Cult of the Valaraukar] May 4 2006 10:21 AM EDT

private!

Maelstrom May 4 2006 10:45 AM EDT

Unless you've already changed your code based on private's suggestions, I have no idea what he's talking about! ;)

The code looks fine to me, and I didn't notice any problems when it ran.

SNK3R May 4 2006 2:05 PM EDT

I haven't changed my code at all. There are, after all, several ways to code the same thing. Of course, I've never seen private's way of doing something, and it looks pretty interesting. I'll have to try it out later.

In addition, Brendan gave me a pretty good idea regarding an addition to my program, which involves making a pie-chart and splitting it up into the percentages of the A's, B's, etc. So, right now, I've been trying to hash out a graphical version via Java applet. Unfortunately, though, my instructor hasn't given us much of any information regarding GUI or applets, so I'm trying to learn as I go for stuff I don't quite understand. Hopefully I'll be able to make a graphical version since my DOS version is already completed.

Any additional suggestions/comments are very welcome. ;) Thanks for taking the time to look!

YOU May 4 2006 2:30 PM EDT

this is simple program. i have useful idea which has been welcome before in my old old old old class. When students grade point average gets too low, the curve occurs. Of course it's your program's job to figure out the approx. curve should be. Remember, Grade A's curve should be smaller than B's. This should be fun for your program and very useful (in school at least).
This thread is closed to new posts. However, you are welcome to reference it from a new thread; link this with the html <a href="/bboard/q-and-a-fetch-msg.tcl?msg_id=001nMH&msg_id=001nMH">Suggestions for my Java program (and need testers).</a>