حل السؤال
حل السؤال 43
import 'dart:io';
void main() {
stdout.write('Enter employment type (Government Employee g, G or Other d, D): ');
String? employmentType =
stdin.readLineSync()?.toUpperCase();
stdout.write('Enter total work duration (in months): ');
int? months = int.tryParse(stdin.readLineSync()
?? '0');
if (employmentType == null || months == null
|| months < 1) {
print('Invalid input.');
return;
}
double years = months / 12;
int leaveEntitlement = 0;
if (employmentType == 'G') {
if (years < 1) {
leaveEntitlement = 0;
} else if (years <= 10) {
leaveEntitlement = 20;
} else {
leaveEntitlement = 30;
}
} else if (employmentType == 'D') {
if (years < 1) {
leaveEntitlement = 0;
} else if (years < 6) {
leaveEntitlement = 14;
} else if (years < 15) {
leaveEntitlement = 20;
} else {
leaveEntitlement = 26;
}
} else {
print('Invalid employment type.');
return;
}
if (leaveEntitlement == 0) {
print('Sorry, you are not entitled to leave as you have not completed one year.');
print('Work duration = $months months = ${years.toStringAsFixed(2)} years.');
} else {
print('Work duration = $months months = ${years.toStringAsFixed(2)} years.');
print('Annual leave entitlement = $leaveEntitlement days.');
}
}

