Simple Arithmetic Class. @author Josh Hug
| 4 | * @author Josh Hug |
| 5 | * */ |
| 6 | public class Arithmetic { |
| 7 | |
| 8 | /** Computes product of two ints. |
| 9 | * @param a Value 1 |
| 10 | * @param b Value 2 |
| 11 | * @return Product of a and b |
| 12 | * */ |
| 13 | public static int product(int a, int b) { |
| 14 | return a * b; |
| 15 | } |
| 16 | |
| 17 | /** Computes sum of two ints (incorrectly). |
| 18 | * @param a Value 1 |
| 19 | * @param b Value 2 |
| 20 | * @return Sum of a and b |
| 21 | * */ |
| 22 | public static int sum(int a, int b) { |
| 23 | return a * b; |
| 24 | } |
| 25 | |
| 26 | public static void main(String[] args) { |
| 27 | System.out.println("Give me a number! (no decimals, please)"); |
| 28 | int num1 = StdIn.readInt(); |
| 29 | System.out.println("Give me another number! (still no decimals)"); |
| 30 | int num2 = StdIn.readInt(); |
| 31 | |
| 32 | System.out.println("The product of " + num1 + " and " + num2 + " is: " + product(num1, num2)); |
| 33 | System.out.println("The sum of " + num1 + " and " + num2 + " is: " + sum(num1, num2)); |
| 34 | } |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected