forked from sagargoswami2001/Java-Lab-File-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ13_SumAndSub_Pack.java
More file actions
30 lines (26 loc) · 790 Bytes
/
Copy pathQ13_SumAndSub_Pack.java
File metadata and controls
30 lines (26 loc) · 790 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
//Q13. WAP to create a package Calc with methods Sum() & Sub() and show the Implementation in a class.
package JAVA_Lab_File;
import Calc.Add;
import Calc.Subtract;
import java.util.Scanner;
public class Q13_SumAndSub_Pack {
public static void main(String[] args)
{
System.out.println("Sum ");
System.out.println("Subtract ");
System.out.print("Enter your choice: ");
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
switch (t) {
case 1 -> {
Add a = new Add();
a.sum();
}
case 2 -> {
Subtract s = new Subtract();
s.subtract();
}
default -> System.out.println("invalid choice");
}
}
}