File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes the smallest number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "the smallest number" Watch "the smallest number" New topic
Author

the smallest number

palestine
Greenhorn

Joined: Nov 05, 2003
Posts: 3
who can help how to writ an application that find the smallest of several number.Assume the first value read specifies number of values to input from the user
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11498
    
  16

once you have all the numbers, read the first one. by definition, it is the smallest. save it in a variable called something like currentSmallest.
then, look at each successive number in turn. if it is smaller than what you have saved, save it in currentSmallest.
when you have scanned all the input numbers, currentSmallest will be holdings the value you want.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

I think we should start responding to requests for the community to do someone's homework in the style of an obfuscated code contest like the International Obfuscated C Code Contest. The student may learn something trying to figure out what the code does and would be less likely to just turn that code in lest the instructor ASK how the code works. I wish I had the time to obfuscate printing out a copyright notice or something of that nature. Just in case a student resorted to outright plagarism.


[How To Ask Questions On JavaRanch]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11498
    
  16

Joe,
do you think i gave too much away? i was trying to be general enough (i figured this was probably a homework, so i didn't post any actual code). i remember sometimes the homeworks are so overwhelming - you can't write any code, because you don't know the algorithm, but you can't test an algorithm because you don't know how to write the code...
i can try and be more vague in the future if you think this was too much...
thanks
f
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Originally posted by fred rosenberger:
do you think i gave too much away?
No, I think your answer was perfect.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

Originally posted by Thomas Paul:
No, I think your answer was perfect.

Agreed. To be clear, I was typing at the same time Fred was, so my comments don't reference his. I was trying to think of a way to respond to homework questions other than the Boilerplate Homework Response (i.e. try to write some code and ask a specific question. . .).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the smallest number