Re: i'm a new java user i'm having problems with my program using the try and catch
- From: Patricia Shanahan <pats@xxxxxxx>
- Date: Sun, 15 Oct 2006 15:35:59 GMT
judith wrote:
judith wrote:....Dear someone who can helpThe problem that i'm having is the followingMicrosoft Windows XP
This program is supposed to calculate the average of N integers. The
program should prompt the user to enter the value for N and then
afterword ,ist emter all N numbers. If the user enters a non- positive
value for N then an exception should be thrown (and caught) with the
message "N must be positive. If there is any exception as the user is
entering the N numbers an error message should be displayed and the
user prompted to enter the number again.
[Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\judith spurlock>path=c:\Program
Files\Java\jdk1.5.0_01
\bin
C:\Documents and Settings\judith spurlock>cd\
C:\>java program3JS
How many numbers do you want to enter?
4
Enter number 1
-2
Enter number 2
-3
Enter number 3
4
Enter number 4
-3
The average is -1.0
C:\>java program3JS
How many numbers do you want to enter?
3
Enter number 1
1
Enter number 2
t
Error, please enter the number again
C:\>Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
The next thing you need to do is play-the-computer. Get a *** of paper
and put the names of your variables across the top. Write down the
initial value underneath each variable name.
Next, work through your program a line at a time. Every time you think a
variable gets a new value, cross out the last value under that variable
and write in the new one. Every time there is an if/while etc., make the
decision according to the last value under each variable on the paper.
See what goes wrong. Once you have found what is going wrong, think
about how to change your program to make it go right.
Patricia
.
- Follow-Ups:
- References:
- Prev by Date: Re: J2ME internationalization
- Next by Date: Re: Math.Floor
- Previous by thread: Re: i'm a new java user i'm having problems with my program using the try and catch
- Next by thread: Re: i'm a new java user i'm having problems with my program using the try and catch
- Index(es):