Click here to Skip to main content
15,908,112 members
Home / Discussions / Java
   

Java

 
PinnedForum Guidelines - PLEASE READ Pin
Chris Maunder28-Jul-09 2:36
cofounderChris Maunder28-Jul-09 2:36 
QuestionMy java output is running but the output does not follow assignment format Pin
Olivia824-Mar-24 20:18
Olivia824-Mar-24 20:18 
AnswerRe: My java output is running but the output does not follow assignment format Pin
OriginalGriff24-Mar-24 20:24
mveOriginalGriff24-Mar-24 20:24 
QuestionJava assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
Olivia824-Mar-24 6:23
Olivia824-Mar-24 6:23 
I have an assignment where the main class output mentions Index 1 out of bounds for length 1 and im trying to read a csv file which has 4 rows and 4 columns below is my code and csv file. Please help the assignment is due tonight at midnight Eastern time :/ I am in my first year of computer science and the assignment is for my introduction of Object-oriented programing, I still consider myself beginner.

main class:

Java
public static void main(String[]args) {
		String relativePath = "data/technicians 2.numbers";
		List<BaseTechnician> technicians = new ArrayList<>();

		
		try {
			
			List<String[]> data = CSVReader.readTechnicians(relativePath);
			
			if(data != null) {
		
		
		for(String[]technician : data) {
			String position = technician[0];
			String name = technician[1];
			String technicianId = technician[2];
			double salaryOrHourlyRate = Double.parseDouble(technician[3]);
			
			BaseTechnician emp;
			switch(position) {
			case " Fulltime ":
			 emp = new FullTimeTechnician(name, technicianId,salaryOrHourlyRate);
			break;
			case " PartTime ":
			 emp = new PartTimeTechnician(name, technicianId, salaryOrHourlyRate);
				break;
				default:
					System.out.println(" Wrong technician position ");
					continue;
			}
			technicians.add(emp);
			
			for(BaseTechnician tech : technicians ) {
				tech.displayDetails();
				System.out.println(" Calculated Salary : " + tech.calculateSalary());
				System.out.println();
			}
			
		}
		} else {
			System.out.println("Error Failed to read data from the technician CSV file ");
		}
		
	} catch (Exception e) {
		System.out.println(" Error occured " + e.getMessage() );
	}
		
	}
	
	
}


and csv file:

CSV
FullTime	David Jonathan	FT1001	50000
PartTime	Keith Peters	PTE 2001.00	24.5
FullTime	Mary Aramal	FTE1003	60000
PartTime	Hassan Otosh 	PTE 2002.00	30.5
FullTime	Bernard Becker	FTE1004	40000
PartTime	Roselyn Anne	PTE 2003.00	24.5
FullTime	James Lead	FTE1005	80000


modified 24-Mar-24 12:35pm.

AnswerRe: Java assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
OriginalGriff24-Mar-24 6:28
mveOriginalGriff24-Mar-24 6:28 
GeneralRe: Java assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
Olivia824-Mar-24 10:11
Olivia824-Mar-24 10:11 
GeneralRe: Java assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
OriginalGriff24-Mar-24 20:19
mveOriginalGriff24-Mar-24 20:19 
GeneralRe: Java assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
jschell26-Mar-24 12:03
jschell26-Mar-24 12:03 
AnswerRe: Java assignmnent due tonigh!! error message "Index 1 out of bounds for length 1" Pin
jimakoskx24-Mar-24 22:30
jimakoskx24-Mar-24 22:30 
GeneralSecurity Manager gone Pin
jschell20-Mar-24 12:52
jschell20-Mar-24 12:52 
Questionlarge numbers Pin
mike741114-Jan-24 12:58
mike741114-Jan-24 12:58 
AnswerRe: large numbers Pin
Pete O'Hanlon14-Jan-24 20:47
mvePete O'Hanlon14-Jan-24 20:47 
AnswerRe: large numbers Pin
Richard MacCutchan14-Jan-24 21:42
mveRichard MacCutchan14-Jan-24 21:42 
QuestionPlease help me with this password validation - While Loop Running Once Pin
R1s1ng Phoen1x14-Jan-24 4:35
R1s1ng Phoen1x14-Jan-24 4:35 
AnswerRe: Please help me with this password validation - While Loop Running Once Pin
Richard MacCutchan14-Jan-24 5:15
mveRichard MacCutchan14-Jan-24 5:15 
GeneralRe: Please help me with this password validation - While Loop Running Once Pin
R1s1ng Phoen1x14-Jan-24 5:58
R1s1ng Phoen1x14-Jan-24 5:58 
GeneralRe: Please help me with this password validation - While Loop Running Once Pin
Richard MacCutchan14-Jan-24 6:06
mveRichard MacCutchan14-Jan-24 6:06 
AnswerRe: Please help me with this password validation - While Loop Running Once Pin
Gerry Schmitz14-Jan-24 5:19
mveGerry Schmitz14-Jan-24 5:19 
GeneralRe: Please help me with this password validation - While Loop Running Once Pin
R1s1ng Phoen1x14-Jan-24 5:59
R1s1ng Phoen1x14-Jan-24 5:59 
Questionviewing Java disassembly Pin
mike741111-Jan-24 22:55
mike741111-Jan-24 22:55 
AnswerRe: viewing Java disassembly Pin
Richard MacCutchan11-Jan-24 23:22
mveRichard MacCutchan11-Jan-24 23:22 
GeneralRe: viewing Java disassembly Pin
jschell12-Jan-24 10:13
jschell12-Jan-24 10:13 
GeneralRe: viewing Java disassembly Pin
Richard MacCutchan12-Jan-24 22:09
mveRichard MacCutchan12-Jan-24 22:09 
AnswerRe: viewing Java disassembly Pin
jschell12-Jan-24 10:14
jschell12-Jan-24 10:14 
GeneralRe: viewing Java disassembly Pin
mike741112-Jan-24 10:25
mike741112-Jan-24 10:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.