So I have this practice question where I should create an array with the employee's information and pass it on to the class; there is a problem with my code which I cant seem to figure out.
What the code is meant to do is: Have the information as seen in the code put into an array, then passed to the methods in the class and then printed out to the user. (The code in the class is perfectly fine, hence why it's not included here).
If anyone could help, that'd be awesome.
Thank you.
// Code.
// The Scanners.
Scanner input = new Scanner(System.in);
Scanner scan = new Scanner(System.in);
// Taking Number Of Employees From The User.
System.out.println("How many employees are there: ");
int numberOfEmployees = input.nextInt();
//Creating An Array With The Size Of Employees Entered By The User.
Employee[] E = new Employee[numberOfEmployees];
// Filling Out Information About Employees In Array.
for(int i = 0; i <= E.length-1; i++){
System.out.println("Enter employee " + i + "'s name: ");
String name = scan.nextLine();
System.out.println("Enter employee " + i + "'s birth date: ");
String bday = scan.nextLine();
System.out.println("Enter employee " + i + "'s salary: ");
double salary = input.nextDouble();
System.out.println("Enter employee " + i + "'s overtime: ");
int overtime = input.nextInt();
E[i] = (name, bday, salary, overtime);
}
System.out.println("Employee's Information"
+ "\n----------------------"
+ "\n----------------------");
for(int i = 0; i <= E.length-1; i++){
E[i].print();
}
}