-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_calculator.dart
81 lines (72 loc) · 2.26 KB
/
simple_calculator.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'dart:io';
void main() {
var first_value = 0, second_value = 0, operation = 0;
print("Welcome to simple Calculator!");
print("Enter First Number:");
first_value = int.parse(stdin.readLineSync()!);
print("Enter Second Number:");
second_value = int.parse(stdin.readLineSync()!);
print("Please select the Operation from below:");
print(
" 1.Division \n 2.Multiplication \n 3.Addition \n 4.Subtraction \n 5.Reminder");
operation = int.parse(stdin.readLineSync()!);
switch (operation) {
case 1:
if (second_value == 0) {
print("The $first_value cannot be divide by $second_value");
} else {
print(
"The division of $first_value and $second_value is: ${first_value / second_value}");
}
break;
case 2:
print(
"The multiplication of $first_value and $second_value is: ${first_value * second_value}");
break;
case 3:
print(
"The addition of $first_value and $second_value is: ${first_value + second_value}");
break;
case 4:
print(
"The subtraction of $first_value and $second_value is: ${first_value - second_value}");
break;
case 5:
print(
"The Reminder of $first_value and $second_value is: ${first_value % second_value}");
break;
default:
print("You have entered the wrong operation");
}
// if(operation == 1)
// {
// if(second_value == 0)
// {
// print("The $first_value cannot be divide by $second_value");
// }
// else
// {
// print("The division of $first_value and $second_value is: ${first_value/second_value}");
// }
// }
// else if(operation == 2)
// {
// print("The multiplication of $first_value and $second_value is: ${first_value*second_value}");
// }
// else if(operation == 3)
// {
// print("The addition of $first_value and $second_value is: ${first_value+second_value}");
// }
// else if(operation == 4)
// {
// print("The subtraction of $first_value and $second_value is: ${first_value-second_value}");
// }
// else if(operation == 5)
// {
// print("The Reminder of $first_value and $second_value is: ${first_value%second_value}");
// }
// else
// {
// print("You have entered the wrong operation");
// }
}