-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator_func.dart
63 lines (47 loc) · 1.56 KB
/
calculator_func.dart
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'dart:io';
void main(){
int first_value, second_value, result,action;
double division;
print("Enter first value: ");
first_value = int.parse(stdin.readLineSync()!);
print("Enter second value: ");
second_value = int.parse(stdin.readLineSync()!);
print("please select an action from below:");
print(" 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n");
action = int.parse(stdin.readLineSync()!);
if(action == 1){
result = Addition(first_value, second_value);
print("The Addition of $first_value and $second_value is: $result");
} else if(action == 2){
result = Subtraction(first_value, second_value);
print("The Subtraction of $first_value and $second_value is: $result");
} else if(action == 3){
result = Multiplication(first_value, second_value);
print("The Multiplication of $first_value and $second_value is: $result");
} else if (action == 4){
division = Division(first_value, second_value);
print("The Division of $first_value and $second_value is: $division");
} else{
print("invalid action");
}
}
int Addition(int first_value,int second_value){
int result =0 ;
result = first_value + second_value;
return result;
}
int Subtraction(int first_value,int second_value){
int result =0 ;
result = first_value - second_value;
return result;
}
int Multiplication(int first_value,int second_value){
int result =0 ;
result = first_value * second_value;
return result;
}
double Division(int first_value,int second_value){
double result =0 ;
result = first_value / second_value;
return result;
}