Why won’t my method become defined in Java?

I have the down below code and its allowing me an error saying that readFile method is not defined.Will be issue

twice grades = brand-new doubleSIZE;

Stat statistics = brand-new Stat(grades, count);

Program.out.print(” Input file identify:”);
fileName = check.next();

readFile(fileName);

open String readFile(String name)

for(int when i = 0; when i < DIMENSIONS; i++)

inFile = brand-new Scanner(new File( fileName ));
while(inFile.hasNextDouble())

gradesi = inFile.nextDouble();
i++;

gain gradesi;

inFile.close();

Program.out.print(count);

I coudn’t fully grasp whats taking that approach behind your own code.However, I get modified that code to operate without blunders.Here this is

import java.io.Track;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Reader;

open class StatDriver

open static avoid main (String args)throws IOException

Reader scan = brand-new Scanner (System.in);

final int DIMENSIONS = TWENTY;
int rely = 0;
Chain fileName;

StatDriver data = brand-new StatDriver();

Program.out.print(” Input file identify:”);
fileName = check.next();

twice grades = brand-new doubleSIZE;
grades= data.readFile(fileName);
Program.out.print(grades);

open double readFile(String fileName)throws FileNotFoundException

final int DIMENSIONS = TWENTY;
twice grades = brand-new doubleSIZE;
for(int when i = 0; when i < DIMENSIONS; i++)

Reader inFile = brand-new Scanner(new File( fileName ));
while(inFile.hasNextDouble())

gradesi = inFile.nextDouble();
i++;

gain grades;

a couple of errors
close the main function braces ahead of the starting connected with readFile function
reader object inFile can be local for you to main
DIMENSIONS is area to main
qualities array can be local for you to main
readFile need to return int assortment not String
save the assortment returned by means of readFile within an int array
i consider you making the effort to nest capabilities in java that is definitely wrong

I don’t see some sort of closing on your main() technique.

+add
I set this towards my NetBeans and in addition see that readFile method is supposed to return some sort of String.

inFile can be defined throughout main along with hence is just not available throughout readFile.It is likely you should create inFile any class levels variable or perhaps change the particular statement around readFile that will:
Reader inFile = brand-new Scanner(new File(fileName));

Leave a Reply