Answer to Question #8763 in Java | JSP | JSF for SINETHEMBA

Question #8763
Write a payroll program that prompt a user to Enter his/her name, hourly rate, working hours in the week and display the amount earning by each employee in Rand.
Note: User is not allowed to enter any negative value for hourly rate and working hours
1
Expert's answer
2012-04-28T09:54:31-0400
package payrollprogram;

import java.util.Scanner;


public class
Main {

private static Scanner input =new Scanner(System.in);
public
static void main(String[] args) {
String name="";
double
hourlyrate=0;
int workinghoursintheweek=0;
double
amountearning=0;
System.out.print("Enter your name:
");
name=input.nextLine();
System.out.print("Enter hourly rate:
");
hourlyrate=Double.parseDouble(input.nextLine());
if(hourlyrate<0){
main(null);
}
System.out.print("Enter
working hours in the week:
");
workinghoursintheweek=Integer.parseInt(input.nextLine());
if(workinghoursintheweek<0){
main(null);
}
amountearning=hourlyrate*workinghoursintheweek;
System.out.print("The
amount earning by "+name+" is: $"+amountearning);
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS