67 020
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #9094 in Java | JSP | JSF for tarik

Question #9094
write a payroll program that prompt a user to Enter his 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.
Expert's answer
import java.util.Scanner;




public class Main {




public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.println("Please, enter your name");

String name = in.nextLine();

System.out.println("Please, enter your hourly rate");

double rate = in.nextDouble();

while(rate <= 0){

System.out.println("Please, enter your hourly rate");

rate = in.nextDouble();

}

System.out.println("Please, enter your working hours in the week");

int hours = in.nextInt();

while(hours <= 0){

System.out.println("Please, enter your working hours in the week");

hours = in.nextInt();

}

int amount = (int) Math.round(hours*rate);




System.out.println();

System.out.println(name);

System.out.println("amount: " + amount);

}

}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions