Switch_case_Example
import "dart:io";
/// Example 1
class Bank {
var sa;
void showDetail() {
print("Employee Name : Hitesh Kachhela");
print("Employee age : 40");
print("Employee phone : 8566321497");
print("Employee salary : 5000");
print("Employee Adhar No : 9644 3218 7455");
}
void taCalculation(int a) {
sa = a;
var ta = (sa * 2)/100;
var da = (sa * 5)/100;
var hra = (sa * 20)/100;
var pf = (sa * 18)/100;
var total_salary = sa + sa;
print("Your TA is : ${ta}");
print("Your DA is : ${da}");
print("Your HRA is : ${hra}");
print("Your PF is : ${pf}");
print("Your Total salary is : ${total_salary}");
}
}
void main() {
Bank object = new Bank();
print("Please Enter the value of Salary : ");
var salary = int.parse(stdin.readLineSync()!);
print("Please Enter the choice from below options : ");
print("1 : (Employee Details)\n2 : (TA, DA, HRA, PF, Total salary calculation)\n");
var option = int.parse(stdin.readLineSync()!);
switch(option) {
case 1 : {
object.showDetail();
} break;
case 2 : {
object.taCalculation(salary);
}
}
}
/// Example 2
// class BankCalculation {
// var sa;
// void showDetail(int b) {
// print("Employee name : Hitesh Kachhela");
// print("Employee age : 40");
// print("Employee phone : 8566321497");
// print("Employee salary : 5000");
// print("Employee Adhar No : 9644 3218 7455");
// }
// void showCalculation(int a) {
// var ta = (5000 * 2)/100;
// var da = (5000 * 5)/100;
// var hra = (5000 * 20)/100;
// var pf = (5000 * 18)/100;
// var total_salary = 5000 + 5000;
// print("TA is : ${ta}\nDA is : ${da}\nHRA is : ${hra}\nPF is : ${pf}\nTotal salary is : ${total_salary}");
// }
// }
// void main() {
// BankCalculation bankObject = new BankCalculation();
//
// print("Please Enter choice from below options : ");
// print("1 : (Employee details)\n2 : (All TA, DA, HRA, PF, Total Salary calculation)");
// var choice = int.parse(stdin.readLineSync()!);
//
// switch(choice) {
// case 1 : {
// bankObject.showDetail(choice);
// } break;
// case 2 : {
// bankObject.showCalculation(choice);
// } break;
// default: {
// print("Please select correct option...");
// }
// }
// }
Comments
Post a Comment