Bob Joness

Greenhorn
+ Follow
since May 20, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Joness

Thanks for the help, i figured it out at last and it works. Today i saw the problem i was having in a whole new light and sorted it out in no time.
19 years ago
Hi, I'm currently working through a book called Java By Dissection (as recommended by my Uni) and i've got really stuck on one of the exercises.
It asks to write a program that reads in integers until a sentinel value of 0 is entered. This is no problem. However it then says that after the sentinel value is entered that the program should print out the smallest number, other than the 0, that was entered by the user.
At the moment the only way i can see of doing this is by creating an array to store the integers that are input by the user in order to search for the smallest value. However as arrays have not yet been introduced in the book i guess they don't expect u to use that method. Each time a new integer is entered the old one gets overwritten due to the fact i only have 1 variable to store it. So how could i get the program to search for the smallest value? There is no limit on the amount of integers to be input otherwise i would create a variable for each integer. Does anyone have any ideas on this?

thanks
19 years ago
yep that fixed it. can't believe how simple it was.

cheers
19 years ago
i'm having compilation problems with this piece of code. The problem is with the 'x' in the lines arrayOfCars[x] = tempBuyCar; and System.out.println(arrayOfCars[x]);

i get the error 'cannot resolve symbol'. however if i replace the x with a number it compiles.

19 years ago