|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
The Handsome Man
![]() ![]() ![]() ![]() 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 |
|
|
|
|
|
#2 (permalink) |
|
I Need a Weapon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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); 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 :. |
|
|
|
|
|
#3 (permalink) |
|
The Handsome Man
![]() ![]() ![]() ![]() 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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|