Question
There are 5 bugs dispersed throughout the methods I'm posting. 2 are syntax bugs and 3 are logic bugs. I was wondering if someone could
There are 5 bugs dispersed throughout the methods I'm posting. 2 are syntax bugs and 3 are logic bugs. I was wondering if someone could highlight them for me and let me know how to fix them.
(This is not a complete code just the few methods that may have bugs in them. Each method will either have 0 or 1 bug.)
public int findHighestMaleSalary() { int dataID = 0; double salary = 0; for(int i = 0; i < data.size(); i++) { if(data.getMaleSalary(i) > salary) { salary = data.getMaleSalary(i); dataID = i; } } return dataID; }
/** * Finds the dataId of the major with the highest starting female salary. * @return dataID - the id of the major with the highest female salary */ public int findHighestFemaleSalary() { int dataID = 0; double salary = 0; for(int i = 0; i < data.size(); i++) { if (data.getFemaleSalary(i) > salary) { salary = data.getFemaleSalary(i); dataID = i; } } return dataID; }
/** * Finds the dataId of the major with the highest starting white salary. * @return dataID - the id of the major with the highest white salary */ public int findHighestWhiteSalary() { int dataID = 0; double salary = 0; for(int i = 0; i < data.size(); i++) { if (data.getWhiteSalary(i) > salary) { dataID = data.getWhiteSalary(i); salary = i; } } return dataID; }
/** * Finds the dataId of the major with the highest starting salary for people of color. * * @return dataID - the id of the major with the highest salary for people of color */ public int findHighestPocSalary() { int dataID = 0; double salary = 0; for(int i = 0; i < data.size(); i++) { if (data.getPocSalary(i) < salary) { salary = data.getPocSalary(i); dataID = i; } } return dataID; }
/** * Finds the dataId of the major with the highest percent males in industry * * @return dataID - the id of the major with the highest percent males in industry */ public int findHighestPercentMales() { int dataID = 0; double percent = 0; for(int i = 0; i < data.size(); i++) { if (data.getMalePercent(i) > percent); percent = data.getMalePercent(i); dataID = i; } return dataID; }
/** * Finds the dataId of the major with the highest percent females in industry * * @return dataID - the id of the major with the highest percent females in industry */ public int findHighestPercentFemales() { int dataID = 0; double percent = 0; for(int i = 0; i < data.size(); i++) { if (data.getFemalePercent(i) > percent) { percent = data.getFemalePercent(i); dataID = i; } } return dataID; }
/** * Finds the dataId of the major with the highest percent whites in industry * * @return dataID - the id of the major with the highest percent whites in industry */ public int findHighestPercentWhite() { int dataID = 0; double percent = 0; for(int i = 0; i < data.size(); i++) { if (data.getWhitePercent(i) > percent) { percent = data.getWhitePercent(i); dataID = i; } } return dataID; }
/** * Finds the dataId of the major with the highest percent people of color in industry * * @return dataID - the id of the major with the highest percent people of color in industry */ public int findHighestPercentPoc() { int dataID = 0; double percent = 0; for(int i = 0; i < data.size(); i++) { if (data.getPocPercent(i) > percent) { percent = data.getPocPercent(i); dataID = 0; } } return dataID; }
/** * Prints a menu that asks for a subset of the data. * * The data subset is always from the split and higher - focused on salaries */
public int calcDiffInGenderSalaries(int dataID) { double diff = 0; double male = data.getMaleSalary(dataID); double female = data.getFemaleSalary(dataID); double average = (male + female) / 2;
diff = (Math.abs(male - female) / average) * 100; return (int)diff; }
/** * Calculate the difference between salaries for a major based on self-identified racial demographics. * * @param dataID the major you wish to look up * @return difference as a whole percent so 15.0010 will return 15. */ public int calcDiffInPocSalaries(int dataID) { double diff = 0; double white = data.getWhiteSalary(dataID); double poc = data.getPocSalary(dataID); double average = (white + poc) / 2;
diff = (Math.abs(white - poc) / average) * 100; return diff; }
/** * This menu helps determine which statistic the client wants to find the highest of. * Is it the highest salary or the highest female salary? Every option that is selected * calls a method that returns a data ID. The full major information should then be * printed using {@link #prettyPrint(int)}. */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started