forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathUtil.java
More file actions
28 lines (25 loc) · 784 Bytes
/
MathUtil.java
File metadata and controls
28 lines (25 loc) · 784 Bytes
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
//Exercise 4-F.
public class MathUtil
{
public static void main(String[] args)
{
printDifference(-4, 5);
printAbsValue(-45);
printDifference(1000, 4000000);
}
private static void printDifference(int a, int b)
{
int difference = a - b;
System.out.println("The values of a and b are: " + a + " and " + b);
System.out.println("This difference between a and b is: " + difference);
System.out.println();
printAbsValue(difference);
}
private static void printAbsValue(int c)
{
int absoluteValue = Math.abs(c);
System.out.println("The value of c is: " + c);
System.out.println("The absolute value of c is: " + absoluteValue);
System.out.println();
}
}