-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.dart
More file actions
33 lines (27 loc) · 831 Bytes
/
Copy pathcalc.dart
File metadata and controls
33 lines (27 loc) · 831 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
31
32
import 'dart:io';
void main(){
print("Enter first number: ");
int firstn = int.parse(stdin.readLineSync()!);
// parse() converts string into int
// stdin >> standard input, readLineSync() read input from the user
print("Enter second number: ");
int secn = int.parse(stdin.readLineSync()!);
print("Enter the operator (+,-,*,/): ");
String? oper = stdin.readLineSync();
if(oper == "+"){
int sum = firstn + secn;
print("$firstn + $secn = $sum");
}
else if(oper == "-"){
int sub = firstn - secn;
print("$firstn - $secn = $sub");
}
else if(oper == "*"){
int multi = firstn * secn;
print("$firstn * $secn = $multi");
}
else if(oper == "/"){
double div = firstn / secn;
print("$firstn / $secn = $div");
}
}