Write a Java program named Salary.java
that determines whether or not each person
in a group of persons is above or below the average salary for the group.
The input will be n pairs of strings and salaries representing the
names of each person and their salary. For example:
java Salary nels 105000.80 mary 20000.50 frank 18153.33 nancy 91868.73 michelle 20858
Your program should print each name and true if the person's salary is above
the average salary for the group and false otherwise (if the salary
equals the average, then output false). For example:
average salary = 51,176.27
nels 105,000.80 true
mary 20,000.50 false
frank 18,153.33 false
nancy 91,868.73 true
michelle 20,858.00 false
You should be able to use the array search program covered in class and
shown in the example code as a guide. A few notes:
- Your error checking should be limited to ensuring that the user
enters an even number of arguments (since the arguments come in
pairs) and that the user provides at least one pair of
arguments. You may assume that the salaries represent valid numbers.
- Your output formatting should be as follows:
- names left justified in a field 15 characters wide.
String objects can be printed using %s.
- salaries should be printed right justified
in a field 10 characters wide
with two decimal points. There should be a thousands
- true/false should be left-justified with no field width
- the average salary should be left justified in a field
10 characters wide with two decimal points, and a
- You can use System.out.printf to format your output. %b will
print a boolean as true/false, %n should be used instead of \n to
print a new line character, and %, to start your formatting statement
for a number will use a comma as a thousands separator. The rest of
printf works just like in C.
- You must declare a class to store a person's information. Name
this class Person.
Since it only needs to be used by your
Salary class, you should nest it within the Salary class (that way
you also only need to use one file).
- Store the objects in an array.
- You can use the parseDouble method from the Double class
to convert a string to a double.