Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. My java output is running but the output does not follow assignment format

My java output is running but the output does not follow assignment format

Scheduled Pinned Locked Moved Java
javahelpcareer
2 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Olivia8
    wrote on last edited by
    #1

    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,80000

    my 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 ");
    	}
    	
    }
    

    }

    OriginalGriffO 1 Reply Last reply
    0
    • O Olivia8

      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,80000

      my 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 ");
      	}
      	
      }
      

      }

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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!

      "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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups