Pairs Assignment
|
AP Computer Science Principles |
Name: |
_____________________ |
|
Lab: Pairs |
Period: |
_____________________ |
.
Assignment
Write a program Pairs that prompts the user to enter two numbers (double) and then prints the addition, subtraction, multiplication, and division of the two numbers.
Pseudocode
1. Import Scanner
2. Construct a Scanner object
3. Print a message that asks the user for the first number.
4. Save the first number in a variable.
5. Print a message that asks the user for the second number.
6. Save the second number in a variable.
7. Use a combination of String literals and double variables to display the addition of the two numbers in an SOP (System.out.println()).
8. Use a combination of String literals and double variables to display the subtraction of the two numbers in an SOP (System.out.println()).
9. Use a combination of String literals and double variables to display the multiplication of the two numbers in an SOP (System.out.println()).
10. Use a combination of String literals and double variables to display the division of the two numbers in an SOP (System.out.println()).
Sample Output
----jGRASP exec: java Pairs
Please enter the first number:
7
Please enter the second number:
13
7.0 + 13.0 = 20.0
7.0 - 13.0 = -6.0
7.0 * 13.0 = 91.0
7.0 / 13.0 = 0.5384615384615384
----jGRASP: operation complete.
Submission
Be sure to submit a screenshot showing your program’s output in addition to your source code (Pairs.java). When taking your screenshot, use the numbers featured in the Sample Output.
Lab: Pairs
1