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); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment