Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi I need help with java project, please follow the instruction. Here is the Source code link for (TestScoreReader): http://www.jade-cheng.com/hpu/2012-spring/csci-2912/text-processing-and-wrapper-classes-ii/TestScoreReader.java. import java.io.*; import java.util.Scanner; /**
Hi I need help with java project, please follow the instruction.
Here is the Source code link for (TestScoreReader): http://www.jade-cheng.com/hpu/2012-spring/csci-2912/text-processing-and-wrapper-classes-ii/TestScoreReader.java.
import java.io.*;
import java.util.Scanner;
/**
The TestScoreReader class reads test scores as
tokens from a file and calculates the average
of each line of scores.
*/
public class TestScoreReader
{
private Scanner inputFile;
private String line;
/**
The constructor opens a file to read
the grades from.
@param filename The file to open.
*/
public TestScoreReader(String filename)
throws IOException
{
File file = new File(filename);
inputFile = new Scanner(file);
}
/**
The readNextLine method reads the next line
from the file.
@return true if the line was read, false
otherwise.
*/
public boolean readNextLine() throws IOException
{
boolean lineRead; // Flag variable
// Determine whether there is more to read.
lineRead = inputFile.hasNext();
// If so, read the next line.
if (lineRead)
line = inputFile.nextLine();
return lineRead;
}
/**
The getAverage method calculates the average
of the last set of test scores read from the file.
@return The average.
*/
public double getAverage()
{
int total = 0; // Accumulator
double average; // The average test score
// Tokenize the last line read from the file.
String[] tokens = line.split(",");
// Calculate the total of the test scores.
for (String str : tokens)
{
total += Integer.parseInt(str);
}
// Calculate the average of the scores.
// Use a cast to avoid integer division.
average = (double) total / tokens.length;
// Return the average.
return average;
}
/**
The close method closes the file.
*/
public void close() throws IOException
{
inputFile.close();
}
}
And (TestAverages) source code: http://www.jade-cheng.com/hpu/2012-spring/csci-2912/text-processing-and-wrapper-classes-ii/TestAverages.java?
import java.io.*; // Needed for IOException
/**
This program uses the TestScoreReader class
to read test scores from a file and get
their averages.
*/
public class TestAverages
{
public static void main(String[] args)
throws IOException
{
double average; // Test average
int studentNumber = 1; // Control variable
// Create a TestScoreReader object.
TestScoreReader scoreReader =
new TestScoreReader("Grades.csv");
// Display the averages.
while (scoreReader.readNextLine())
{
// Get the average from the TestScoreReader.
average = scoreReader.getAverage();
// Display the student's average.
System.out.println("Average for student " +
studentNumber + " is " +
average);
// Increment the student number.
studentNumber++;
}
// Close the TestScoreReader.
scoreReader.close();
System.out.println("No more scores.");
}
}
The table is the data that you use to build the table you will be creating in your database. If you run the program as is, and use that table which is an excel sheet, the program will read the data in that sheet. The project needs to create the database and a table and load records into this table, then change the program to read this table instead if reading it from the excel sheet
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