ava coding please Problem: Winston-Salem State University’s Office of Budget Man
ID: 3773813 • Letter: A
Question
ava coding please
Problem: Winston-Salem State University’s Office of Budget Management has decided to review the possibility of giving its faculty raises for the 2010-2011 Academic Year. The percentage of raise each faculty member receives will be based on years of service and academic status (tenure/tenure track-1or non tenure track-2). See chart below to determine percentage raise.
Years of Service
Tenure/Tenure Track
Non-Tenure Track
25 or more
8%
4%
15-24
6%
3%
6-14
4%
2%
0-5
2%
1%
They have contracted you to prepare a report based on the information in the database (textfile) and project the cost to the University. The database (budget.txt) contains the following information:
-Name - String
-Years of Service - Integer
-Academic Status ( 1 – Tenure/Tenure-Track, 2 – Non-Tenure Track)
-Current Yearly Salary - Double
Sample Data:
Caldwell, E./25/1/117000
Secondly, they need you to prepare a report containing the following information:
1-Read and display the contents of the file.
2-Determine and display the name and percentage raise for each faculty member.
3-Compute and display the name and amount of raise each faculty member will receive.
4-Compute the new salary for each faculty member.
5-Display name, old salary, and new salary for each faculty member.
6-Display the total additional cost to the university if a raise is given for the 2010-2011 Academic Year.
here is the data file
CSUData.txt
Here is the sampleOutput
Name years of service statut Current yearly Salary
---------------------------------------------------------------------------------
Name Purcentage raise
-----------------------------------------------------------------------------------
Name Raise
----------------------------------------------------------------------------------
Name old salary new salary
--------------------------------------------------------------------------------
Total cost:
31780.0
Years of Service
Tenure/Tenure Track
Non-Tenure Track
25 or more
8%
4%
15-24
6%
3%
6-14
4%
2%
0-5
2%
1%
Explanation / Answer
// name of file should be passed in args[0]
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class HelloWorld {
public static void main(String[] args) {
int bool = 0;
String Name = "";
String Years_of_Service = "";
String Academic_Status = "";
String Current_Yearly_Salary = "";
File file = new File(args[0]);
if (!file.exists()) {
System.out.println(args[0] + " does not exist.");
return;
}
if (!(file.isFile() && file.canRead())) {
System.out.println(file.getName() + " cannot be read from.");
return;
}
try {
FileInputStream fis = new FileInputStream(file);
char current;
while (fis.available() > 0) {
current = (char) fis.read();
if(current == ' ')
{
bool = 0;
System.out.println("Name: " + Name );
System.out.println("Years_of_Service: " + Years_of_Service );
System.out.println("Academic_Status: " + Academic_Status );
System.out.println("Current_Yearly_Salary: " + Current_Yearly_Salary );
int hike=0;
if((Integer.parseInt(Years_of_Service) >= 25) && (Integer.parseInt(Academic_Status) == 1))
{
hike = 8;
}
else if((Integer.parseInt(Years_of_Service) <= 5) && (Integer.parseInt(Academic_Status) == 1))
{
hike = 2;
}
else if((Integer.parseInt(Years_of_Service) < 15) && (Integer.parseInt(Academic_Status) == 1))
{
hike = 4;
}
else if((Integer.parseInt(Years_of_Service) < 25) && (Integer.parseInt(Academic_Status) == 1))
{
hike = 6;
}
else if((Integer.parseInt(Years_of_Service) <= 5) && (Integer.parseInt(Academic_Status) == 2))
{
hike = 1;
}
else if((Integer.parseInt(Years_of_Service) < 15) && (Integer.parseInt(Academic_Status) == 2))
{
hike = 2;
}
else if((Integer.parseInt(Years_of_Service) < 25) && (Integer.parseInt(Academic_Status) == 2))
{
hike = 3;
}
else if((Integer.parseInt(Years_of_Service) > 25) && (Integer.parseInt(Academic_Status) == 2))
{
hike =4 ;
}
String raise = Integer.toString(hike);
System.out.println("Percentage Raise: " + raise );
String actualRaise = Integer.toString((Integer.parseInt(raise) * (Integer.parseInt(Current_Yearly_Salary))/100));
String raiseAmount = Integer.toString((Integer.parseInt(actualRaise) - Integer.parseInt(Current_Yearly_Salary)));
System.out.println(" New Salary: " + actualRaise );
System.out.println(" Raise Amount: " + raiseAmount );
}
else if(current == '/')
{
bool = bool + 1;
}
if(bool == 0)
{
Name = Name + current;
}
else if(bool == 1)
{
Years_of_Service = Years_of_Service + current;
}
else if(bool == 2)
{
Academic_Status = Academic_Status + current;
}
else if(bool == 3)
{
Current_Yearly_Salary = Current_Yearly_Salary + current;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.