Results 1 to 4 of 4
  1. #1
    Polyy is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Lightbulb Java Beginner needs urgent help!

    I want to find out the max and min of the numbers in all the arrays, how would I do that?? I know how to find max and min when using int values (Math.max) but in this array I have strings, so how do i do it?

    P.S. I have to make a program that takes in a basketballs team statistics and prints out the player with the most rebounds, the player with the most assits and the player with the most points

    Here is the code:
    Java Code:
    String[] Rebounds = new String [12]; //make an array for rebounds for each player
                Rebounds [0] = "4.90"; //save 4.90 as trevor arizas rebounds
                Rebounds [1] = "5.10"; //save 5.10 as kobe bryant rebounds
                Rebounds [2] = "8.90"; //save 8.90 as andrew bynum rebounds
                Rebounds [3] = "3.40"; //save 3.40 as Jordan Farmer rebounds
                Rebounds [4] = "2.60"; //save 2.60 as Derek Fisher rebounds
                Rebounds [5] = "10.10"; // save 10.10 as Pau Gasol rebounds
                Rebounds [6] = "1.30"; // save 1.30 as Chris Mihm rebounds
                Rebounds [7] = "5.90"; // save 5.90 as Lamar Odom rebounds
                Rebounds [8] = "1.80"; // save 1.80 as Josh Powell rebounds
                Rebounds [9] = "3.30"; // save 3.30 as Vladimir Radmanovic rebounds
                Rebounds [10] = "1.90";  // save 1.90 as Sasha Vujacic rebounds
                Rebounds [11] = ".40"; // save .40 as Luke Walton rebounds
    
                String[] Points = new String [12]; //make an array that shows the points for each player
                Points [0] = "9.4"; //save 9.4 as trevor arizas points
                Points [1] = "24.4"; //save 24.4 as kobe bryant points
                Points [2] = "9.2"; //save 9.2 as andrew bynum points
                Points [3] = "10.2"; //save 10.2 as Jordan Farmer points
                Points [4] = "10.6"; //save 10.6 as Derek Fisher points
                Points [5] = "17.6"; // save 17.6 as Pau Gasol points
                Points [6] = "4.7";  // save 4.7 as Chris Mihm points
                Points [7] = "9.3"; // save 9.3 as Lamar Odom points
                Points [8] = "2.8"; // save 2.8 as Josh Powell points
                Points [9] = "6.1"; // save 6.1 as Vladimir Radmanovic points
                Points [10] = "5.2"; // save 5.2 as Sasha Vujacic points
                Points [11] = ".6"; // save .6 as Luke Walton points
    
                String[] Assists = new String [12]; //make an array that shows the assists for each player
                Assists [0] = "1.7"; //save 1.7 as trevor arizas assists
                Assists [1] = "4.0"; //save 4.0 as kobe bryant assists
                Assists [2] = "1.8"; //save 1.8 as andrew bynum assists
                Assists [3] = "2.9"; //save 2.9 as Jordan Farmer assists
                Assists [4] = "2.7"; //save 2.7 as Derek Fisher assists
                Assists [5] = "3.1"; // save 3.1 as Pau Gasol assists
                Assists [6] = ".0"; // save .0 as Chris Mihm assists
                Assists [7] = "2.2"; // save 2.2 as Lamar Odom assists
                Assists [8] = ".0"; // save .0 as Josh Powell assists
                Assists [9] = "1.1"; // save 1.1 as Vladimir Radmanovic assists
                Assists [10] = "1.4"; // save 1.4 as Sasha Vujacic assists
                Assists [11] = ".6"; // save .6 as Luke Walton assists

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    One way to help motivate folks to help you is to always respond to their posts before posting a new thread. Best of luck.

  3. #3
    Polyy is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    oh, i am sorry, i should have thanked you, please forgive my stupid mistake.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default hhhmmm... maybe this...

    In a for loop:
    • read each element from the array
    • convert to int (hint: google "java convert string to int")
    • compare with the next element (math.max?)
    • if first is greater than, keep and use for the next compare.
    • If not, discard and use next element for the the next compare
    • etc.


    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Java Beginner needs help!!
    By Polyy in forum New To Java
    Replies: 4
    Last Post: 11-23-2008, 03:11 AM
  2. Replies: 4
    Last Post: 09-13-2008, 12:07 PM
  3. Urgent Java programmer needed.
    By KevinG in forum Jobs Offered
    Replies: 5
    Last Post: 04-23-2008, 05:02 AM
  4. beginner to Java
    By notwist in forum New To Java
    Replies: 15
    Last Post: 04-18-2008, 10:41 AM
  5. Urgent Requirement for Java/J2ee
    By anushareddy7480 in forum New To Java
    Replies: 0
    Last Post: 07-23-2007, 12:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •