java
import.java.io.*;
//The PayrollPartThree class just wraps the main method required to run the program
public class employee{
public static void main( String args[] ) {
String empl_Name = "";
int empl_number;
String empl_pos;
double Hourly_Rate = 0.0;
double HoursInWeek = 0.0;
//double totalWeeklyWage = 0.0;
EmployeeRecord employee;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String cleanInputBuffer = "";
final String ERROR_MESSAGE = "*ERROR: Value must be greater than or equal to 0.\n";
final String STOP = "stop";
//Print out a title banner (optional)
System.out.printf( "*****************************" );
System.out.printf( "Payroll Program " );
System.out.printf( "*****************************\n" );
while ( true ) {
System.out.println(""Please enter the employee name ");
employeeName = input.nextLine();
if ( employeeName.equalsIgnoreCase( STOP ) ) {
break;
}
System.out.println ( "\nPlease enter the employee's number ");
empl_pos = input.nextLine();
System.out.println("Please enter the employee's hourly wage in rands : R" );
hourlyWageInDollars = input.nextDouble();
while ( hourlyWageInDollars < 0.0 ) {
System.out.println( ERROR_MESSAGE );
hourlyWageInDollars = input.nextDouble();
}
*/
System.out.println("Please enter the employee's weekly hour worked : " );
hoursWorkedInWeek = input.nextDouble();
while ( hoursWorkedInWeek < 0.0 ) {
System.out.println( ERROR_MESSAGE );
do
System.out.println( HOURS_PROMPT );
hoursWorkedInWeek = input.nextDouble();
}
cleanInputBuffer = input.nextLine();
// totalWeeklyWage = hourlyWageInDollars * hoursWorkedInWeek;
//Create the EmployeeRecord object (employee) by calling its constructor
employee = new EmployeeRecord(empl_Name, empl_pos, hourly_Rate,hoursInWeek;
//Display the employee information
System.out.println( "\n-------------Summary------------\n" );
System.out.println( "Employee : %s\n" , employee.getEmpl_Name() );
System.out.println( "Employee : %s\n" , employee.getEmpl_number() );
System.out.println( "Hourly Wage : $%.2f\n" , employee.getHourly_Rate() );
System.out.println( "Hours Worked: %.2f\n" , employee.getHoursInWeek() );
// System.out.println( "Weekly Wage : $%.2f\n" , employee.getWeeklyWageInDollars() );
}
}
}
/*Write a program using Java programming language that calculates employees’ salary by capturing personnel number and hours per week. The program should then search the table below to determine the rate per hour that will be used to calculate the salary according to the following logic:
If hours per week is less or equal to 40, then salary is rate per hour times hours per week.
The rate per hour becomes one and half for hour above 40 and up to 50.
The rate per hour doubles for every hour above 50.
Calculate the 40% for every employee.
Personnel Number Employee Name Position Rate/Hour
4583170 Myburgh S Artisan R50.00
4583171 Miller B Technician R75.00
4583172 Cook R Engineer R90.00
4583173 Jones V Manager R100.00
*/
*edit: Please use code tags in the future, thanks!
This post has been edited by Martyr2: 17 Mar, 2008 - 10:18 AM