Skip to content

Commit c107f69

Browse files
committed
Compute Two Numbers
1 parent a4695b4 commit c107f69

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

‎src/Assignments/Problems.java‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,33 @@ public class Problems {
88
public static void main(String[] args) {
99

1010
Problems problems = new Problems();
11-
problems.calculateSimpleInterest();
11+
// problems.calculateSimpleInterest();
12+
Scanner firstInput = new Scanner(in);
13+
out.println("Enter FirstNumber: ");
14+
int firstNumber = firstInput.nextInt();
15+
16+
Scanner secondInput = new Scanner(in);
17+
out.println("Enter SecondNumber: ");
18+
int secondNumber = secondInput.nextInt();
19+
20+
Scanner symbolInput = new Scanner(in);
21+
out.println("Enter Formula(Ex:- +,-,*,/): ");
22+
String symbol = symbolInput.next();
23+
24+
problems.computateTwoNumbers(firstNumber,secondNumber,symbol);
25+
}
26+
27+
void computateTwoNumbers(int firstNumber, int secondNumber, String symbol){
28+
29+
switch (symbol) {
30+
case "+", "addition", "add" -> out.println("Addition of Two Numbers is " + (firstNumber + secondNumber));
31+
case "-", "difference", "minus" -> out.println("Difference of Two Numbers is " + (firstNumber - secondNumber));
32+
case "*", "multiply" -> out.println("Multiplication of Two Numbers is " + (firstNumber * secondNumber));
33+
case "/", "divide" -> out.println("Division of Two Numbers is " + (firstNumber / secondNumber));
34+
default -> out.println("No valid formula Provided!!");
35+
}
36+
37+
// out.println("Addition");
1238
}
1339

1440
void calculateSimpleInterest(){

0 commit comments

Comments
 (0)