School of Computing recently hired interns who had completed their Higher Certificate degree. You are one of those interns. You have been tasked to develop a Java program that will calculate the net pay for each of the interns. You have been provided with a textfile called interns.txt with the following intern details: employee number, name, sex, gross pay, and deductions. Below are the contents of the file:
Figure 1 Interns.txt file
1
Develop a Java program using the information provided in the above scenario. The program must consist of two functions namely interns() and ladies(). The interns() function must initially read, from the interns.txt, records containing the following fields: employee number, name, sex, gross pay, and deductions. The program must then calculate the net pay for each intern using the formula:
nett pay = gross pay – deductions
What I have tried:
package cliff;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Program {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(
"C:\\Users\\user\\OneDrive - University of Mpumalanga\\Desktop\\cliff.txt"));
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
String[] parts = line.split(",");
for (String part : parts) {
System.out.println("Num:" + part);
}
System.out.println();
}
reader.close();
}
}