Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The text book I am using is introduction to java programming 9th edition. Progra

ID: 3531305 • Letter: T

Question

The text book I am using is introduction to java programming 9th edition.

Programming exercise 14.25 at page 558 of the textbook. (Process large dataset) A university posts its employees' salaries at http://cs.armstrong.edu/liang/data/Salary.txt. Each line in the file consists of a faculty member's first name, last name, rank, and salary (see Exercise 14.24). Write a program to display the total salary for assistant professors, associate professors, full professors, and all faculty, respectively, and display the average salary for assistant professors, associate professors, full professors, and all faculty, respectively. Hint: Reference to Exercise 14.24 is given for providing an example. The solution to Programming Exercise 14.25 is not related to Exercise 14.24, so it is not displayed here.

Explanation / Answer

import java.util.*;


class Assignment

{

public static void main(String args[])

{

Scanner s=new Scanner(new BufferedReader(new FileReader("salary.txt")));

String strLine;

string firstname;

string lastname;

string rank;

int salary;

int totalsalaryforassociate=0;

int totalsalaryforassitant=0;

int totalsalaryforprofessor=0;

int totalsalaryforallfaculty=0;

int averagesalaryforassociate=0;

int averagesalaryforprofessor=0;

int averagesalaryforassistant=0;

int averagesalaryforallfalculty=0;


int nooffaculty=0;

int noofassistant=0;

int noofassociate=0;

int nooffullprof=0;


while (s.hasNext())

{

firstname=s.next();

lastname=s.next();

rank=s.next();

salary=s.nextInt();

if(rank="assitantprofessor")

{

totalsalaryforassociate=totalsalaryforassociate+salary;

noofassociate++;

}

else if (rank="assistantprofessor")

{

totalsalaryforassitant=totalsalaryforassitant+salary;

noofassistant++;

}

else if(rank='fullprofessor')

{

totalsalaryforprofessor=totalsalaryforprofessor+salary;

nooffullprof++;

}

else

{

totalsalaryforallfaculty=totalsalaryforallfaculty+salary;

nooffaculty++;

}

}

averagesalaryforassociate=totalsalaryforassociate/noofassociate;

averagesalaryforprofessor=totalsalaryforprofessor/nooffullprof;

averagesalaryforassistant=totalsalaryforassitant/noofassistant;

averagesalaryforallfalculty=totalsalaryforallfaculty/nooffaculty;



System.out.println("Average salary for associate "+averagesalaryforassociate+" Total "+totalsalaryforassociate;

System.out.println("Average salary for full professor "+averagesalaryforprofessor+" Total "+totalsalaryforprofessor;

System.out.println("Average salary for assistant"+averagesalaryforassistant+" Total "+totalsalaryforassitant;

System.out.println("Average salary for faculty "+averagesalaryforallfalculty+" Total "+totalsalaryforallfaculty;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote