Results 1 to 10 of 10
Thread: Need help with homework
- 02-11-2011, 01:21 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
- 02-11-2011, 01:30 AM #2
The first problem is that you set value and prevalue to v. Does that sound right to you? I would have thought you set prevalue to the last value the user entered not the current one. And you would only do that for a given situation such as IF the current value is greater than the previous value. Also, you might find this simpler if you use a boolean in the while loop instead.
- 02-11-2011, 01:43 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
So how would I set prevalue to the last value while being able to enter in a new value ? sorry if im asking a dumb question im new to java and like I said, Im having a hard time learning this because I have to rely solely on the book.
- 02-11-2011, 01:47 AM #4
Well everything depends upon what the current value the user enters. So how about after you get the value and store it into v* why not do a few tests to see if it is a valid input and what happens next is determined by those tests. I gave you a capital hint in my previous reply.
*you can actually do away with the v variable but lets not worry about that right now.
- 02-11-2011, 01:57 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
I think i get where you are going so I got this so far but im still having the same issue
I know this is such a simple problem but my brain is so fried right now from an exam I have tomorrow as wellLast edited by bkim33; 02-11-2011 at 05:36 AM.
- 02-11-2011, 02:14 AM #6
You have four conditions and you have only handled one.
1. If value is outside acceptible range
2. If input is not an integer. Check with teacher if you need to handle this one.
3. If current value is less than previous value
4. Happy days - valid input so we can do stuff.
Also, examine your if statement carefully. What happens if user enters -1?
- 02-11-2011, 02:15 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
ok I made a lot of progress!! thanks a lot sir!
I stil have the issue of the initial value of 50 if i enter something larger than 50 I will have issues..Last edited by bkim33; 02-11-2011 at 05:36 AM.
- 02-11-2011, 02:18 AM #8
Now you have handled 2 of the possible 4 situations. Keep going.
- 02-11-2011, 04:38 AM #9
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
I made a variable of count initialized to 0 above the while loop; under else part of the loop i put count ++; after the while loop i print out the variable sum but the loop runs twice and stops why is this happening?
- 02-11-2011, 04:50 AM #10
Similar Threads
-
Need some help with my homework.
By JacobM in forum New To JavaReplies: 11Last Post: 02-04-2011, 02:42 AM -
Homework help please
By chick in forum New To JavaReplies: 22Last Post: 03-19-2010, 07:39 AM -
Homework help
By rclausing in forum New To JavaReplies: 26Last Post: 11-24-2009, 06:06 AM -
Please Help with Homework
By theuser in forum Advanced JavaReplies: 2Last Post: 07-30-2009, 03:37 PM -
Homework help...
By robrobrob in forum New To JavaReplies: 4Last Post: 10-17-2008, 04:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks