Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
About Us Register FAQ Members List Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old May 18th, 2004   #1 (permalink)
The Handsome Man
 
Sampah's Avatar
 
Join Date: Nov 2002
Location: Unlucky Place
Posts: 881
Need help in Java Programming

ok... I just entered my Java programming class for second time and the lecturer give me some damn superior homework. I can't answer the last two question which told me to do this:

accept 3 Integer from user abd display the max and min number.
example: value 1: 2
value 2: 3
value 3: 4
Max value: 4
Min Value: 2

I know how to do "accept 3 Integer from user" but I don't know how to display the min and max number, can anyone teach me how to write a command to display the maximum and minimum value in Java?
__________________
PROCESSOR: AMD Athlon 64 3000+ @1.8Ghz RAM: Kingstone 512MB PC3200 MOBO: ECS Nforce4 A939
VGA: Pixelview Geforce 6600GT (Golden Limited Edition) 128MB OS: WinXP pro Service pack 2
Sampah is offline   Reply With Quote
Old May 18th, 2004   #2 (permalink)
I Need a Weapon
 
FLaRe85's Avatar
 
Join Date: Oct 2001
Location: Omaha, NE
Posts: 4,321
min() and max() functions already exist within Java: http://java.sun.com/j2se/1.4.2/docs/...ax(int,%20int)

This most certainly isn't the best way for large groups of numbers, but it's perfectly fine if you only have 3 integers. Let's just call the integers a, b, and c and then we'll create an additional temp variable called x.

Code:
x = min(a, b);
minvalue = min(x, c);

x = max(a, b);
maxvalue = max(x, c);
Then just output as usual:
Code:
System.out.println("The minimum value was: " + minvalue);
System.out.println("The maximum value was: " + maxvalue);
__________________
.: Flaretech.Net :: Flaretech.Biz Web Hosting :: H3 Stats :: My Blog :.



.: Mac Pro :: Dual Quad-Core Intel Xeon 5400s :: 6 GB 800MHz DDR2 ECC FB-DIMMs :: NVIDIA GeForce 8800 GT 512 MB GDDR3 :.
.: Macbook Pro 17" :: 2.33 GHz Intel Core 2 Duo :: 2 GB 667 MHz DDR2 :: ATI Radeon X1600 :.
.: Home Server :: 2.41 GHz AMD Opteron 180 :: 4 GB DDR400 :: Windows Server 2003 Enterprise R2 :.
FLaRe85 is offline   Reply With Quote
Old May 19th, 2004   #3 (permalink)
The Handsome Man
 
Sampah's Avatar
 
Join Date: Nov 2002
Location: Unlucky Place
Posts: 881
Many Thanks, can you tell me where to find details about java packages?

EDIT: cool! I found it on the link above, Thanks in advance
__________________
PROCESSOR: AMD Athlon 64 3000+ @1.8Ghz RAM: Kingstone 512MB PC3200 MOBO: ECS Nforce4 A939
VGA: Pixelview Geforce 6600GT (Golden Limited Edition) 128MB OS: WinXP pro Service pack 2

Last edited by Sampah; May 19th, 2004 at 05:38.
Sampah is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:57.

© 2006 - 2008 Emu Forums | About Emu Forums | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.7.0 Release Candidate 3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5