Related questions with answers
Question
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 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.
Solution
VerifiedAnswered 2 months ago
Answered 2 months ago
Step 1
1 of 5import java.io.File;
import java.io.FileNotFoundException;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Process {
public static void main(String[] args) throws FileNotFoundException {
DecimalFormat df2 = new DecimalFormat("#.##");
double assistantT = 0, associateT = 0, fullT = 0;
int assistantC = 0, associateC = 0, fullC = 0;
//URL url = new URL("http://cs.armstrong.edu/liang/data/Salary.txt");
//Scanner input = new Scanner(url.openStream());
Scanner input = new Scanner(
new File("12_Chapter\\25_Process_dataset\\Salary.txt"));
while (input.hasNextLine()) {
String line;
line = input.nextLine();
String[] attributes = line.split("\\s+");
switch (attributes[2]) {
case "assistant":
assistantC++;
assistantT += Double.parseDouble(attributes[3]);
break;
case "associate":
associateC++;
associateT += Double.parseDouble(attributes[3]);
break;
case "full":
fullC++;
fullT += Double.parseDouble(attributes[3]);
break;
}
}
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition•ISBN: 9780124077263David A. Patterson, John L. Hennessy226 solutions

Intro to Java Programming, Comprehensive Version
10th Edition•ISBN: 9780133761313Y. Daniel Liang1,628 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe895 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848 (5 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen849 solutions
More related questions
1/4
1/7