我正在编写一个简单的 Perl 脚本,该脚本根据用户给出的小时数计算付款,该程序不得允许超过 500 小时的付款,但必须允许女性最多 600 小时,我正在使用 except 函数,但它不起作用女性的工作时间可以超过600小时。
这是我使用的代码
print("Enter your working hours");
$hours=<stdin>;
print("Enter your gender");
$gender=<stdin>;
chomp($gender);
unless($gender ne "f" && $hours>=600){
print("Your have earned ",$hours*10," Birr \n");
}
else{
unless($hours>=500){
print("Your have earned ",$hours*10," Birr \n");
}
else{
print("You have worked beyond the payable hrs!");
}
}
Run Code Online (Sandbox Code Playgroud)