aspose file tools*
The moose likes Beginning Java and the fly likes Java Grading System Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Grading System" Watch "Java Grading System" New topic
Author

Java Grading System

J Rock
Greenhorn

Joined: Feb 27, 2010
Posts: 5
Hey guys, im pretty new to java as this is my first time ever taking such a course, and i have an assignment that i have to complete that im stuck on and i have no idea what to do next.

Heres what i have so far, and i doubt its right



Now, what i have to do is create a method getLetterGrade, which i think i have done correctly, and i also have to have it so it outputs the class average, the class minimum, and the class maximum as letter grades. So im stuck because i have to make it ask the user how many grades there putting in and such to get the average, min, and max, but i first have to figure out how i could get the average which is where im stuck. Hopefully you guys can help., and if you dont understand really what im asking, i can just put the actual question in for you.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18833
    
  40

J Rock wrote:
So im stuck because i have to make it ask the user how many grades there putting in and such to get the average, min, and max, but i first have to figure out how i could get the average which is where im stuck.


Well, it depends on where the data is stored (after you asked the user for the data). The average is a straightforward mathematical calculation. It is merely, the sum of the numbers divided by how many numbers.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

Welcome to JavaRanch!

Your method looks good. As far as entering grades, why do you have to know how many grades the user is entering before you start? What if you kept track yourself? You can keep a variable to count how many grades have been entered so far. Think about the two pieces of info needed to calculate an average (sum and count). You can see that the total number of grades isn't needed until the very end.

If you are stuck, try a smaller problem - prompt the user to enter a single grade and read it in. Then add a loop and have the user continue entering grades until they enter a special flag to say they are done.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
J Rock
Greenhorn

Joined: Feb 27, 2010
Posts: 5
So should i do the average in my main, or should i make a method for it?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

J Rock wrote:So should i do the average in my main, or should i make a method for it?

Up to you. The average is only one line of code after all. I would focus on getting it working before worrying about something cosmetic like that*.

* Note this advice only applies while you are very new to Java. After a while, you'll have a feel for what goes in a method. And have longer programs. At which point, I no longer recommending dumping extra things in main().
J Rock
Greenhorn

Joined: Feb 27, 2010
Posts: 5
Ok, another question i have, how could i make it so it prints out the lowest and the highest grade that it receives?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

First of all you need something which would keep track of lowest and highest grades. Then every time the code receives a grade, it should ask whether that grade is now the lowest, or the highest. Printing those things out is of course the easy part.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3014
    
  10
J Rock wrote:Ok, another question i have, how could i make it so it prints out the lowest and the highest grade that it receive


Well, have you been able to do the average? Can you show us what you did? If not, it's probably better to concentrate on one part of the problem at a time.

Also, looking back at what you've shown so far... what happens in your method getLetterGrade() if the value of average is, say, 71.3? I mean, exactly what happens? Look through the code and try to predict the outcome. Then, compile it and run it, and see if you were right.

Actually, maybe that should have been the first question: does your code even compile? (For what you've shown above, no, it doesn't - but maybe you've fixed it since then.) If not, focus on why it doesn't compile, and fix it, before adding even more code. Otherwise you're just making problems harder and harder to diagnose. Compile and run your code frequently, with only small changes in between. That way, any time it was compiling, and then it stops compiling, you know that the error must be somewhere in the small changes you've added since last time. (Well, usually.) This makes it much easier to track down problems.
J Rock
Greenhorn

Joined: Feb 27, 2010
Posts: 5
Well, i've been asking so many questions because i have to have it finished by tomorrow at midnight, and it compiles for me, but i really have done much except what is there because i've been doing other things
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
J Rock wrote:Well, i've been asking so many questions because i have to have it finished by tomorrow at midnight, and it compiles for me, but i really have done much except what is there because i've been doing other things


I'm not sure how we are to respond to this other than to encourage you to put other things to the side and now concentrate on this program and on learning Java (which is no easy task when you're just starting out). Oh and to also wish you luck!
J Rock
Greenhorn

Joined: Feb 27, 2010
Posts: 5
Yea, thanks anyways, i'll just turn in what i got and just take that, next time i'll be sure to get to this earlier ;)
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3014
    
  10
Fair enough. But we can also give more useful feedback if we see what you've done so far. I know for a fact that the code you showed initially does not compile, so if you now have something that does compile, please show us how it's been modified, and that might be a good starting point for further progress.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Grading System