-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapterTwoSumAndPower.java
More file actions
23 lines (19 loc) · 967 Bytes
/
ChapterTwoSumAndPower.java
File metadata and controls
23 lines (19 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Chapter2;
import java.util.Scanner;
public class ChapterTwoSumAndPower {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the first number: ");
int number1 = input.nextInt();
System.out.println("Enter the second number: ");
int number2 = input.nextInt();
int sum = number1 + number2;
int squareOfSum = (number1 + number2) * (number1 + number2);
int difference = number1 - number2;
int squareOfDifference = (number1 - number2) * (number1 - number2);
System.out.printf("The Sum of the two numbers is: %d%n%n", sum);
System.out.printf("The square of the sum of the two numbers is: %d%n%n", squareOfSum);
System.out.printf("The difference of the two numbers is: %d%n%n", difference);
System.out.printf("The square of the difference of the two numbers is: %d%n%n", squareOfDifference);
}
}