A small application I wrote for someone to calculate a salary.
GeSHi (java):
import java.util.InputMismatchException;
import java.util.Scanner;
public class Employee {
static double hourlyRate = 0.0;
static double hoursWorked = 0.0;
public static void main
(String[] args
){ Scanner sc =
new Scanner
(System.
in);
try{
System.
out.
print("Employee name: ");
System.
out.
print("Hourly rate $");
hourlyRate = sc.nextDouble();
System.
out.
print("Hour(s) worked: " );
hoursWorked = sc.nextDouble();
System.
out.
println("Employee " + name +
" " +
"with an hourly rate of $" + hourlyRate +
" earned $" + getPay
() + " by working " + hoursWorked + " hours a week.");
}
catch(InputMismatchException IMME){
System.
out.
println("Input not correct!");
}
}
public static double getPay(){
double pay = hourlyRate * hoursWorked;
return pay;
}
}
Created by GeSHI 1.0.7.20
Output:Employee name: Micheal
Hourly rate $9,50
Hour(s) worked: 32
Employee Micheal with an hourly rate of $9.5 earned $304.0 by working 32.0 hours a week.
Additionally, check out my blogpost here:
http://www.engineeringser...ecutive-and-hourlyworker/ for the pdf format and the other classes.