Question: whats wrong with my code: / * * Click nbfs: / / nbhost / SystemFileSystem / Templates / Licenses / license - default.txt to change
whats wrong with my code:
Click nbfs:nbhostSystemFileSystemTemplatesLicenseslicensedefault.txt to change this license
package cpanlabstarter;
import java.ioBufferedReader;
import java.ioFile;
import java.ioFileReader;
import java.ioFileWriter;
import java.ioIOException;
public class Main
public static void mainString args
final int size ;
Professor professors new Professorsize;
Student students new Studentsize;
int pInt ;
int sInt ;
try
FileReader fr new FileReadernew FilePeopletxt;
BufferedReader br new BufferedReaderfr;
String line;
while line brreadLine null
String parts line.split;
String title parts;
String name parts;
String major parts;
System.out.printlntitle;
System.out.printlnname;
System.out.printlnmajor;
if titleequalsProfessor
String department parts;
professorspInt new Professortitle name, department;
else if titleequalsStudent
String degree parts;
studentssInt new Studenttitle name, degree;
brclose;
frclose;
catch IOException e
System.out.printlnProfessors:;
for int i ; i pInt; i
System.out.printlnprofessorsi;
System.out.println
Students:";
for int i ; i sInt; i
System.out.printlnstudentsi;
writeToFileprofessors pInt, "Professor.txt;
writeToFilestudents sInt, "Student.txt;
private static void writeToFilePerson people, int count, String fileName
try
FileWriter w new FileWriterfileName;
for int i ; i count; i
wwritepeopleitoString
;
wclose;
catch IOException e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
