Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How do I call the loadDataFromFile function in the main method? public static void main ( String [ ] args ) { loadDataFromFile (
How do I call the loadDataFromFile function in the main method? public static void mainString args
loadDataFromFile;
Scanner scanner new ScannerSystemin;
int choice;
Display the menu and process user input until the user chooses to exit.
do
displayMenu;
System.out.printEnter your choice: ;
choice scanner.nextInt;
switch choice
case :
displayAllRecords;
break;
case :
displaySelectedRecordscanner;
break;
case :
displayCumulativeStatisticscanner;
break;
case :
displayHistogramscanner;
break;
case :
System.out.printlnExiting the program. Goodbye!";
break;
default:
System.out.printlnInvalid choice. Please try again.";
while choice ;
scanner.close;
private static void displayMenu
System.out.println
Menu:";
System.out.println Display all records";
System.out.println Display selected record";
System.out.println Display cumulative statistic";
System.out.println Display histogram";
System.out.println Exit";
Loads data from a file into the program.
@param fileName The name of the data file.
private static int loadDataFromFileRecord dataRecords
Scanner scanner new ScannerSystem in;
try
File file new FilePhoenixSunsDatatxt;
Scanner inFile new Scannerfile;
do
dataRecordsnumRecords new Record;
dataRecordsnumRecordskey inFile.next;
dataRecordsnumRecordsfield inFile.next;
dataRecordsnumRecordsfield inFile.nextDouble;
dataRecordsnumRecordsfield inFile.nextDouble;
numRecords;
whiledataRecordsnumRecordskey.equals;
numRecords;
catchIOException ioe
System.out.printlnFile access error";
numRecords ;
return numRecords;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started