Switch_case_Dart

 import "dart:io";


class Task {
var value1, value2;

void addition(int a, int b) {
value1 = a;
value2 = b;
var sum = value1 + value2;
print(sum);
}
void subtraction(int c, int d) {
value1 = c;
value2 = d;
var sub = value1 - value2;
print(sub);
}
void multiplication(int e, int f) {
value1 = e;
value2 = f;
var mul = value1 * value2;
print(mul);
}
void division(int a, int b) {
value1 = a;
value2 = b;
var div = value1 / value2;
print(div);
}
}
void main() {
Task object = new Task();
print("Please Enter the value of Number 1 : ");
var no1 = stdin.readLineSync();
print("Please Enter the value of Number 2 : ");
var no2 = stdin.readLineSync();
print("Please select choice from below options: ");
print("1 : (Addition)\n2 : (Subtraction)\n3 : (Multiplication)\n4 : (Division)");
print("Enter your choice : ");
var choice = int.parse(stdin.readLineSync()!);

switch(choice) {
case 1 : {
print("Sum is : ");
object.addition(int.parse(no1!), int.parse(no2!));
} break;
case 2 : {
print("Subtraction is : ");
object.subtraction(int.parse(no1!), int.parse(no2!));
} break;
case 3 : {
print("Multiplication is : ");
object.multiplication(int.parse(no1!), int.parse(no2!));
} break;
case 4 : {
print("Division is : ");
object.division(int.parse(no1!), int.parse(no2!));
} break;
default: {
print("Please Select correct choice");
}
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Pagination with Bloc Pattern in Flutter

If_Else_Example