-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverloadClient.java
More file actions
39 lines (29 loc) · 966 Bytes
/
OverloadClient.java
File metadata and controls
39 lines (29 loc) · 966 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
29
30
31
32
33
34
35
36
37
38
39
public class OverloadClient
{
public static void main(String[] args)
{
OverloadClass quinn = new OverloadClass(); // instantiate the object
int num1=0, num2=0, num3=0, answer=0;
System.out.println("Would you like to add 2 or 3 numbers?");
int howMany = SavitchIn.readLineInt();
if (howMany == 2)
{
System.out.print("\nEnter the first number: ");
num1 = SavitchIn.readLineInt();
System.out.print("Enter the second number: ");
num2 = SavitchIn.readLineInt();
answer = quinn.add(num1, num2);
}
else
{
System.out.print("\nEnter the first number: ");
num1 = SavitchIn.readLineInt();
System.out.print("Enter the second number: ");
num2 = SavitchIn.readLineInt();
System.out.print("Enter the third number: ");
num3 = SavitchIn.readLineInt();
answer = quinn.add(num1, num2, num3);
}
System.out.println("The answer is " + answer + "\n\n");
}
}