My code outputs this for some reason. The first four are supposed to be the empl
ID: 3743366 • Letter: M
Question
My code outputs this for some reason. The first four are supposed to be the employees I'm supposed to find. The fifth one(NaN), is supposed to output the average pay of employees that work in a certain department. Please help, I don't know what I'm doing wrong.
package data; //D.Lopes //8.29.18 //Employee Class Assignment public class Employee f //data variables private String lastName; private String firstName; private String jobTitle; private String department; private double salary; //default constructor public Employee) this.lastName"Luna" this.firstName"Anthony" this.jobTitle -"Firefighter" this.department "Fire"; this. Salary 0; //constructor public Employee(String lastName, String firstName, String jobTitle, String department, double salary) this, lastName = lastName; this.firstName = firstName; this. jobTitle JobTitle; this.department - department; this.salary-salary //getters and setters for last name public String getLastName) { return lastName; public void setLastName (String lastName) this.lastNamelastName; //getters and setters for first name public String getFirstName() { return firstName; public void setFirstName (String firstName) { this.firstName -firstName; //getters and setters for job title public String getJobTitle() { return jobTitle; public void setJobTitle(String jobTitle) 5 this.jobTitle - jobTitle;Explanation / Answer
Please print the values in the arrays once we completed reading from file, the issue seems to be with reading otherwiese everything looks fine, your getting NAN because the divison is happening 0/0 as array is empty
Note:Please comment below for any further discussion
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.