forked from haonlywan/CodeHS-Java-APCSA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.7.7 Pretty Printing Operations (Part 1)
29 lines (28 loc) · 1.16 KB
/
2.7.7 Pretty Printing Operations (Part 1)
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
import java.util.Scanner;
public class CalculatorTester
{
public static void main(String[] args)
{
// Put your code here
// A good place to start is to
// create comments to remind yourself
// what you need to do
Scanner input = new Scanner(System.in);
//gather two doubles from the user
System.out.println("Enter one double:");
double double1 = input.nextDouble();
System.out.println("Enter another double:");
double double2 = input.nextDouble();
//store results
Calculator calc = new Calculator();
calc.sum(double1, double2);
calc.multiply(double1, double2);
calc.divide(double1, double2);
calc.subtract(double1, double2);
//printing out results
System.out.println(double1 + " + " + double2 + " = " + calc.sum(double1, double2));
System.out.println(double1 + " - " + double2 + " = " + calc.subtract(double1, double2));
System.out.println(double1 + " * " + double2 + " = " + calc.multiply(double1, double2));
System.out.println(double1 + " / " + double2 + " = " + calc.divide(double1, double2));
}
}