![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Dec 2005
Posts: 8
Rep Power: 0
![]() |
Java help please?
Hey people. I'm sure this will be simple for someone in here. I am new to Java programming and am having a hell of a time trying to solve my problem.
Anyway, I am writing a program that prompts the user to enter 3 scores, multiplies the scores by the weights of the tests and then outputs the lettergrade. I have a loop setup to restart the program if they enter a character instead of a number. I also have it setup so that if they enter a score between 0 and 100 the program terminates, however I would prefer to have it re-ask the user to enter the information. Any help would be greatly appreciated. Here is the code: http://pastebin.com/458716 Thanks people. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 5
![]() |
I can guarantee that after you figure this out, it will be simple for you also. I took a quick glance at your code, and there are not any huge errors there (except for swallowing your exception, but that isn't an error as much as not following conventions)..
What specifically do you need help with? Judging by your comments, and what I see in your code, you already know how to do what you want to do. ![]()
__________________
HijackThis Team-SFDC |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Dec 2005
Posts: 8
Rep Power: 0
![]() |
Yep. You are right, I figured it out. haha.
What should I do with the exception to follow conventions? Someone had helped me with the exception part ![]() Thanks. Here are the changes I made http://pastebin.com/458804 |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 5
![]() |
It is generally bad form to swallow an exception. What I mean by swallowing it is that in your try/catch loop, you should at a minumum have a stack dump. That way if there is an error, you will have some clue. Otherwise your application will continue on as though nothing happened, except that you may get bad results. At a minimum, you should have:
e.printStackTrace(); ![]() EDIT: errm, you should do this:
} catch(Exception e)
{
e.printStackTrace();
}Your code works though, so you can leave it alone....
__________________
HijackThis Team-SFDC |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|