Calculating max field goal percentage in a method in java program -


The field goal of the team is to find both the maximum and the minimum in the set of data.

  Import java.io. *; Import java.util.Scanner; Public class Kastatababal {public static wide man (sting [] AGRs) throws filenoutound expansions {scanner in = new scanner (new file ("data 1wt"); String [] first name = new string [100]; String [] lastname = new string [100]; Int fgm [] = new int [100]; Int fga [] = new int [100]; Double FGP = 0; Intestinal maxFGP; Int Min FGP; System.out.print ("player FGM FGA FGP% \ n"); Int count = 0; For (int i = 0; in.hasNext (); i ++) {first name [i] = in.next (); Last name [i] = in.next (); Fgm [i] = in.nextInt (); FGA [i] = in.nextInt (); FGP = (1.0 * FGM [I]) / (1.0 * FGA [I]) * 100; Count ++; System.out.printf ("% 10s% 10s% 3d% 3d% 3.1f \ n", first name [i], last name [i], fgm [i], FGA [i], fgp); } MaxFGP = maxFGP (FGM, FGA, count); Min FGP = MinFGP (FGM, FGA, Count); System.out.printf ("\ n \ nThe player with the highest field target percentage is:% 3d", maxFGP (fgm, fga, count)); System.out.printf ("\ n Player is the lowest field target percentage:% 3.1f", fgp); } Public static integer maxFGP (int [] fgm, int [] fga, int count) {int max = 0; For (int i = 0; i  13+I ++) (if (FGM [i]> FGM [count]) = i;} return minute;}}  

The "if" statement is needed for the correct maximum return.

We are our percentage for all players, but it is necessary to use the greatest field target percentage Together with ways to find the player and the least.

Here's a data file:

  Marcus Foster 123 288 Thaw S Gipson 102 178 Shane Southwell 88 224 Spreading 58 144 Wesley Ewondo 53 111 Nino Williams 49 9 9 Nigel Johnson 28 80 Bioson Thomas 15 58 DJ Johnson 34 68 Omry Lawrence 27 65 Sean Mayer 2 Ryan Schultz 29 Jack Katatain 1 Brian Roller 1 2  

should be like this:

  Public static integer maxFGP (int [] fgm, int [] fga, int count) {int max = 0; double max value = (1.0 * FGM [0]) / (1.0 * FGA [0]) * 100; (Int i = 0; i  

Note: You already have int max = 0; , so there is no need for loop from i = 0 . Change int i = 1

  Change system to print the  name  of the maximum value player Printf ("\ n \ nThe player with the highest field goal percentage is:% 3d", first name [maxFGP (fgm, fga, count)]);  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -