My java output is running but the output does not follow assignment format
-
How can my output have the same structure/output as the sample output
Technician ID: FT1001
Name: David Jonathan
Salary: 50000.0
Calculated Salary: 50000.0
Technician ID: PTE2001
Name: Keith Peters
Salary: 24.5
Calculated Salary: 980.0
Technician ID: FTE1003
Name: Mary Aramal
Salary: 60000.0
Calculated Salary: 60000.0
my output :
FullTime,David Jonathan,FT1001,50000
PartTime,Keith Peters,PTE2001,24.5
FullTime,Mary Aramal,FTE1003,60000
PartTime,Hassan Otosh ,PTE2002,30.5
FullTime,Bernard Becker,FTE1004,40000
PartTime,Roselyn Anne,PTE2003,24.5
FullTime,James Lead,FTE1005,80000my main class :
public static void main(String[]args) {
String relativePath = "data/technicians.csv";
List<BaseTechnician> technicians = new ArrayList<>();List<String\[\]> data = CSVReader.readTechnicians(relativePath); if(data != null) { for(String\[\]technician : data) { String position = technician\[0\]; BaseTechnician emp; switch(position) { case " Fulltime ": emp = new FullTimeTechnician(technician\[1\], technician\[2\],Double.parseDouble(technician\[3\])); break; case " PartTime ": emp = new PartTimeTechnician(technician\[1\], technician\[2\],Double.parseDouble(technician\[3\])); break; default: System.out.println( position); continue; } technicians.add(emp); for(BaseTechnician tech : technicians ) { tech.displayDetails(); } } } else { System.out.println("Error Failed to read data from the technician CSV file "); } }
}
-
How can my output have the same structure/output as the sample output
Technician ID: FT1001
Name: David Jonathan
Salary: 50000.0
Calculated Salary: 50000.0
Technician ID: PTE2001
Name: Keith Peters
Salary: 24.5
Calculated Salary: 980.0
Technician ID: FTE1003
Name: Mary Aramal
Salary: 60000.0
Calculated Salary: 60000.0
my output :
FullTime,David Jonathan,FT1001,50000
PartTime,Keith Peters,PTE2001,24.5
FullTime,Mary Aramal,FTE1003,60000
PartTime,Hassan Otosh ,PTE2002,30.5
FullTime,Bernard Becker,FTE1004,40000
PartTime,Roselyn Anne,PTE2003,24.5
FullTime,James Lead,FTE1005,80000my main class :
public static void main(String[]args) {
String relativePath = "data/technicians.csv";
List<BaseTechnician> technicians = new ArrayList<>();List<String\[\]> data = CSVReader.readTechnicians(relativePath); if(data != null) { for(String\[\]technician : data) { String position = technician\[0\]; BaseTechnician emp; switch(position) { case " Fulltime ": emp = new FullTimeTechnician(technician\[1\], technician\[2\],Double.parseDouble(technician\[3\])); break; case " PartTime ": emp = new PartTimeTechnician(technician\[1\], technician\[2\],Double.parseDouble(technician\[3\])); break; default: System.out.println( position); continue; } technicians.add(emp); for(BaseTechnician tech : technicians ) { tech.displayDetails(); } } } else { System.out.println("Error Failed to read data from the technician CSV file "); } }
}
Look at your
BaseTechnician.displayDetails
method: it's the one that outputs the details, and it appears to do it as a single line. That will need to be changed to add the line breaks and extra text your assignment requires."I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!