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

12.25 (Process large dataset) A university posts its employees salaries at http:

ID: 3907965 • Letter: 1

Question


12.25 (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 Programming Exercise 12.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 Program 2.15 points: Work programming exercise 12 25, page 491, to design and develop a java program to process large data sets (call it ProcessData Set java) Please follow the specifications given in the problem statement. Test the program as stated in the problem statement Please write this Java program using the intructions above. Please use comments throughout explaining what is happening. Thank you

Explanation / Answer

import java.io.*;
import java.util.*;

public class Demo200{

    public static void main(String[] args){
         try{

              FileInputStream fin = new FileInputStream("salary.txt");
              Scanner fc = new Scanner(fin);
              double total = 0;
              double totalAsstProf = 0;
              double totalAssocProf = 0;
              double totalFullProf = 0;
              int countTotal = 0;
              int countAsstProf = 0;
              double countAssocProf = 0;
              double countFullProf = 0;
              while(fc.hasNextLine()){
                   String line = fc.nextLine();
                   String[] list = line.split(" ");
                   countTotal++;
                   total = total + Double.parseDouble(list[3]);
                   if (list[2].equals("associate")){
                      totalAssocProf = totalAssocProf + Double.parseDouble(list[3]);
                      countAssocProf++;
                   }
                   if (list[2].equals("assistant")){
                      totalAsstProf = totalAsstProf + Double.parseDouble(list[3]);
                      countAsstProf++;
                   }
                   if (list[2].equals("full")){
                      totalFullProf = totalFullProf + Double.parseDouble(list[3]);
                      countFullProf++;
                   }
                  
              }
              double avgAssocProf = totalAssocProf/countAssocProf;
              double avgAsstProf = totalAsstProf/countAsstProf;
              double avgFullProf = totalFullProf/countFullProf;
              double avgProf = total/countTotal;

              System.out.println("Total Assistant Prof Salary:" + totalAsstProf);
              System.out.println("Average Assistant Prof Salary:" + avgAsstProf);
              System.out.println("Total Associate Prof Salary:" + totalAssocProf);
              System.out.println("Average Associate Prof Salary:" + avgAssocProf);
              System.out.println("Total Full Prof Salary:" + totalFullProf);
              System.out.println("Average Full Prof Salary:" + avgFullProf);
              System.out.println("Total Salary:" + total);
              System.out.println("Average total Salary:" + avgProf);
         }
         catch (Exception e){
             e.printStackTrace();
         }
    }
}

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