-
Notifications
You must be signed in to change notification settings - Fork 0
/
GiveMeMyTaxInfo.java
69 lines (50 loc) · 2.62 KB
/
GiveMeMyTaxInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
*********************************************************************************
* dev23jjl DLM: 10/11/2022 GiveMeMyTaxInfo.java
*
* Description: these are the basic required components of a simple Java program
* this program creates character and string variables to hold
* user input and uses the conditional operator, the if statement,
* and the if-else statement to produce output using
* Personalized data for tax amount, gross pay, and net pay
*
*********************************************************************************
*/
import java.io.IOException;
import java.util.Scanner;
public class GiveMeMyTaxInfo {
public static void main(String[] someVariableName) throws IOException {
String userChoice;
String userName;
double hrsWorked = 0;
double payRate = 0.00;
double taxRate1 = 0.25;
double taxRate2 = 0.50;
double grossPay = 0.00;
double taxAmt = 0.00;
double netPay = 0.00;
try (Scanner in = new Scanner( System.in )) {
System.out.println("Please enter your first name ==> \n");
userName = in.next(); // Read the next word from Standard input
System.out.println("Do you want to compute your net pay? \n");
System.out.println("Enter Y for yes or N for no ==> ");
userChoice = in.next(); //read user input and store in
if (userChoice.equals("Y")) {
System.out.println("\n Please enter the number of hours you worked ==>");
hrsWorked = in.nextInt();
System.out.println("\n Please enter your pay rate ==> $");
payRate = in.nextFloat();
grossPay = payRate * hrsWorked;
taxAmt = (grossPay >= 500) ? grossPay * taxRate2 : grossPay * taxRate1;
netPay = grossPay - taxAmt;
System.out.println( "\n " + userName + " you said you worked " + hrsWorked + " hours at $" + payRate + "\n");
System.out.println("which means you earned a gross amount of $" + grossPay + " \n");
System.out.println("and you paid $" + taxAmt + " in taxes\n");
System.out.println("so your net pay is $" + netPay + " \n");
} else {
System.out.println("\n Thank you " + userName + " then I will not computer your net pay \n");
System.out.println(" Thank you and please come again. \n");
}
}
}
}