java - Produce an output report that contains the player name, FGM, FGA, and the field goal percentage i.e. FGP -


I've got my code to compile, but it's saying with a runtime error: java.util.InputMismatchException : Null (In.java.util.Scanner)

Here is my following code:

  import java.io. *; Import java.util.Scanner; Public Class Castetabol {Public Static Zero Main (String [] AGR) File Notepad Exception, IOException {Scanner Infile = New Scanner (New File ("Data 1.txt")); Int count = 1; Int fgm [] = new int [100]; Int fga [] = new int [100]; Double FGP = 0; Int reading, maxFGP, min FGP; Read = readArray (fgm, fga, count, inFile); MaxFGP = maxFGP (FGM, FGA, count); Min FGP = MinFGP (FGM, FGA, Count); System.out.print ("player FGM FGA FGP% \ n"); System.out.printf ("% 15d% 3d% 3d% 2.1f", count, fgm, fga, fgp); System.out.printf ("The player with the highest regional profit:% 3d", fgp); System.out.printf ("The player with the lowest regional goal:% 3d", fgp); InFile.close (); } Static Integratere (Ant.) FGM, Ent [] FGA, Int Count, Scanner Infile) {Double Temp = Infile.Next Double (); Int k; in TV; V = inFile.nextInt (); (K = 0; (v! = - 99 9) & amp; amp; (k & lt; counts; k ++) {FGM [K] = V; V = inFile.nextInt (); } Return K; } Public static integer maxFGP (int [] fgm, int [] fga, int count) {for (int i = 0; i <13; i ++) {if (fgm [i] & lt; fgm [count ]) Count = i; } Calculation of return; } Public constant minFGP (int [] fgm, int [] fga, int count) {for (int i = 0; i> 13; i ++) {if (fgm [i]> fgm [count] ) Number = i; } Calculation of return; }} Here is my data file that I am reading: Marcus Foster 123 288 Thomas Gipsson 102 178 Shane Southwell 88 224 William Spreading 58 144 Wesley Ewundu 53 111 Nino Williams 49 9 9 Nigel Johnson 28 80 Bioson Thomas 15 58 DJ Johnson 34 68 Omri Lawrence 27 65 Sean Mayer 2 4 Ryan Schultz 2 9 Jack Katatane 1 Brian Roheler 1 2-999  

I try to get my output to look as the following Marcus Foster 123 288 42% Thomas Gipson 102 178 57% Shane Southwell 88 224 39% Delay 58 58 40% Wesley Ewundu 53 111 47% Nino Williams 49 96 51% Nigel Johnson 28 80 35% Jevon Thomas 15 58 25% DJ Johnson 34 68 50% Omri Lawrence 27 65 41% Sean Mayer 2 4 50% Ryan Schultz 2922% Jack Katetten 1 4 25% Ryan Roehler 1 2 50%

With the player

Thomas Gibson with the lowest field goal percentage is the lowest field target percentage with 22% Ryan Schulz

java.util.InputMismatchException Throw by java.util.Scanner class When you call a method like nextDouble or nextInt () , when the data read does not match the type that you have asked to read it Its input f Based on Ail, you're trying to read strings as double incorrectly.

  Static Interrend Array (int [] fgm, int [] fga, int count, scanner infile) {double temp = inFile.nextDouble (); Int k; in TV; V = inFile.nextInt (); (K = 0; (v! = - 99 9) & amp; amp; (k & lt; counts; k ++) {FGM [K] = V; V = inFile.nextInt (); } Return K; }  

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 -