-
-
Save JorgeOlvera/7337318 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*4. An employee receives the regular pay rate for the first 30 hours and he is paid 1½ | |
times the normal rate for each hour over the 30 hours. Write a program (save it as | |
BonusWage) that prompts the user for the regular pay rate and the hours worked and | |
then it will calculate and display on screen the employee’s wage based on that | |
information and the criteria mentioned above. For example, if 42 is entered for hours and | |
6.00 for rate, then the amount to display should be $288.00. | |
*/ | |
import java.util.Scanner; | |
import java.io.*; | |
public class BonusWage { | |
public static void main(String[] args) { | |
String wage; | |
String hours | |
Scanner input = new Scanner(System.in); | |
System.out.println("Enter your wage"); | |
wage = input.nextLine(); | |
System.out.println("Enter the amount of hours you worked") | |
hours = input.nextLine(); | |
if (hours <= 30){ | |
System.out.println("Your total salary is:" + wage * hours); | |
} | |
else if (hours > 30) { | |
System.out.println("Your total salary is" + wage * 1.5 *hours) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The second if should be:
System.out.println("Your total salary is" + wage * (30 + 1.5 *(hours-30) ) );
since the 1.5 is applied to each hour in addition to the 30 hours.