-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathOperations.java
More file actions
51 lines (48 loc) · 2.17 KB
/
MathOperations.java
File metadata and controls
51 lines (48 loc) · 2.17 KB
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
/*
*********************************************************************************
* dev23jjl DLM: 9/28/2022 MathOperations.java
*
* Description: These are the basic required components of a simple Java program
* The program declares and manipulates variables using assignment, mathematical,
* and comparison operators and prints these variables to the terminal.
*
*********************************************************************************
*/
public class MathOperations {
public static void main(String[] mathOperations)
{
//Initializes the variables for computation
float hrsWorked = 40;
double payRate = 10.00;
double taxRate1 = 0.25;
double taxRate2 = 0.50;
double grossPay = 0.00;
double taxAmt = 0.00;
double netPay = 0.00;
//Prints out the name of the variable and it's value
System.out.println("hrsWorked= " + hrsWorked);
System.out.println("payRate= $" + payRate);
System.out.println("taxRate1 = " + taxRate1);
System.out.println("taxRate2 = " + taxRate2);
System.out.println("grossPay = " + grossPay);
System.out.println("taxAmt = " + taxAmt);
//Changes the values of grossPay, taxAmt, and netPay based on other variables
//Checks if the grossPay is large (greater than/equal to 500) or small (less than/equal to 500)
grossPay = payRate * hrsWorked;
boolean bigGrossPay = (grossPay >= 500);
taxAmt = grossPay * taxRate1;
boolean littleGrossPay = (grossPay <= 500);
taxAmt = grossPay * taxRate2;
netPay = grossPay - taxAmt;
//Prints out the information
System.out.println("hrsWorked = " + hrsWorked);
System.out.println("payRate = $" + payRate);
System.out.println("taxRate1 = " + taxRate1);
System.out.println("taxRate2 = " + taxRate2);
System.out.println("grossPay = $" + grossPay);
System.out.println("taxAmt = $" + taxAmt);
System.out.println("netPay = $" + netPay);
System.out.println("bigGrossPay = " + bigGrossPay);
System.out.println("littleGrossPay = " + littleGrossPay);
}
}