-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.java
37 lines (27 loc) · 947 Bytes
/
calculator.java
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
/**Author:faraja maha ([email protected])
* Date: monday 5th august 2024
* first subimit
*/
import java.util.*;
public class calculator{
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("ENTER FIRST NUMBER:");
double number1=input.nextDouble();
System.out.println("SHOOSE OPERATOR FROM(+,-,*,/):");
char operator=input.next().charAt(0);
System.out.println("ENTER FIRST NUMBER:");
double number2=input.nextDouble();
operator op=null;
switch(operator){
case'+':
op= new addition();
break;
default:
System.out.println("inter a valid operator bro!");
}
double result= op.calculate( number1,number2);
System.out.println(number1+" "+" "+number2+" " +"=" +result);
//System.out.println("Hello, World!");
}
}