Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 10th, 2005, 2:56 PM   #1
Draconis77
Newbie
 
Join Date: Dec 2005
Posts: 8
Rep Power: 0 Draconis77 is on a distinguished road
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.
Draconis77 is offline   Reply With Quote
Old Dec 10th, 2005, 3:16 PM   #2
groovicus
Programmer
 
Join Date: Nov 2004
Posts: 84
Rep Power: 5 groovicus is on a distinguished road
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
groovicus is offline   Reply With Quote
Old Dec 10th, 2005, 4:15 PM   #3
Draconis77
Newbie
 
Join Date: Dec 2005
Posts: 8
Rep Power: 0 Draconis77 is on a distinguished road
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
Draconis77 is offline   Reply With Quote
Old Dec 10th, 2005, 4:54 PM   #4
groovicus
Programmer
 
Join Date: Nov 2004
Posts: 84
Rep Power: 5 groovicus is on a distinguished road
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
groovicus is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC