File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the smallest number

 
palestine
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fred rosenberger:
do you think i gave too much away?
No, I think your answer was perfect.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. . .).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic