In: Computer Science
The human resources department for your company needs a program that will determine how much to deduct from an employee’s paycheck to cover healthcare costs. Health care deductions are based on several factors. All employees are charged at flat rate of $150 to be enrolled in the company healthcare system. If they are married there is an additional charge of $75 to cover their spouse/partner. If they have children, the cost is $50 per child. In addition, all employees are given a 10% deduction in the total cost if they have declared to be a “non-smoker”.
Your goal is to create a program that gathers the employee’s name, marital status, number of children and whether or not they smoke tobacco for a single employee. While gathering this information, if the user enters at least one invalid value, the program must display one error message telling the user they made a mistake and that they should re-run the program to try again. The program must then end at this point. However, if all valid values are entered, the program should calculate the total cost of the healthcare payroll deduction and then print a well-formatted report that shows the employee’s name, marital status, total number of children, and smoker designation, and total deduction amount.
Please write a pseudocode for the above problem. Don't forget to validate the inputs as necessary.
// Pseudocode to determine how much to deduct from an employee’s paycheck to cover healthcare costs.
Declaration
   string name, marital_status, smoke_tobacco;
   number children, total_deduction;
  
Start
  
   // input of name
   Print("Enter name : ");
   Input name;
  
   // input of marital status
   Print("Enter Marital Status (M/S) : ");
   Input marital_status;
  
   // validate marital status to be "M" or "S"
irrespective of case
   if(marital_status != "M" and marital_status != "m" and
marital_status != "S" and marital_status != "s") then
       Print("Invalid value for marital
status. Please run the program again"); // print error
message
       Exit ; // exit the program
   end if;
  
   // input number of children
   Print("Number of children : ");
   Input children;
  
   // validate number of children cannot be
negative
   if(children < 0) then
       Print("Number of children cannot be
negative. Please run the program again"); // print error
message
       Exit; // exit the program
   end if;
   // input of smoker designation
   Print("Do you smoke(Y/N) : ");
   Input smoke_tobacco;
  
   // validate smoker designation to be "Y" or "N"
irrespective of the case
   if(smoke_tobacco != "Y" and smoke_tobacco != "y" and
smoke_tobacco != "n" and smoke_tobacco != "N"):
       Print("Invalid value for smoking
tobacco. Please run the program again"); // print error
message  
       Exit; // exit the program
   end if;
   // calculate total_deduction
   // set total_deduction to flat rate for all
employees
   total_deduction = 150;
  
   // check if married then add charge to cover
spouse/partner
   if(marital_status == "M" or marital_status == "m")
then
       total_deduction = total_deduction +
75;
   end if;
   // add the charge for each children
   total_deduction = total_deduction + 50*children;
  
   // check if employees is not a smoker then deduct 10%
from total cost
   if(smoke_tobacco == "n" or smoke_tobacco == "N")
then
       total_deduction = total_deduction -
(0.1*total_deduction);
   end if;
   // print employees name , marital status, number of
children, smoker designation and total deduction amount
   Print("Employee Name : ",name);
   Print("Marital Status(M/S) : ",marital_status);
   Print("Total number of children : ",children);
   Print("Smoker Designation(Y/N) :
",smoke_tobacco);
   Print("Total Deduction Amount :
$",total_deduction);
End