So I need to right a program that reads information from an existing file ("WeeklyPayroll.txt"). The file is exactly this:
Jane
Smith
10.50
12
Helen
Clarke
11.50
10
Rain
Parker
10.50
10
I then need to take each employee earnings (the this number line in each pragraph) and calculate sepately their total earnings using their weekly hours (the fourth line in each paragraph). How do I take specific lines from a file? Here's a program i have that simply reads the file and re-prints it. Can someone help me?
import java.io.*;
class txtFile
{
publicstaticvoid main(String[] args) throws IOException
{
FileInputStream file = new FileInputStream("WeeklyPayroll.txt");
InputStreamReader isr = new InputStreamReader(file);
BufferedReader reader = new BufferedReader(isr);
int ch;
while ((ch = reader.read()) != -1)
{
System.out.print((char)ch);
}
isr.close();
file.close();
}
}
Bookmarks