Program HCL (input,output);
CONST
Max=45;
Positive='Qualified';
Negative='Not Qualified';
QualifyClark=10000;
QualifyBGarden=7500;
QualifySkyfall=5500;
BTime=3;
ZERO=0;
BRate=10/100;
CCTime=3/2;
CCRate=15/100;
CUTime=3;
DependentAllowance=75;
Half=1/2;
CORRECT='Approved';
WRONG='Not Approved';
TYPE
StringArray=ARRAY[1..Max] OF String;
RealArray=ARRAY[1..Max] OF Real;
IntegerArray=ARRAY[1..Max] OF Integer;
VAR
ApplicantName:StringArray;
HousingCommunity:StringArray;
ApplicantGrossSalary:RealArray;
ApplicantSalaryDeductions:RealArray;
ApplicantSpouse:StringArray;
SpouseGrossSalary:RealArray;
SpouseSalaryDeductions:RealArray;
ApplicationStatus:StringArray;
FinalApplicationStatus:StringArray;
NetSalaries:RealArray;
ApplicantExpenses:RealArray;
ApplicantRepayments:RealArray;
Applicant:Integer;
Name:String;
Housing:String;
GSalary:Real;
Deductions:Real;
Spouse:String;
SpouseSalary:Real;
SpouseDeductions:Real;
TotalGrossSalary:Real;
TotalSalaryDeductions:Real;
NetSalary:Real;
HalfNetSalary:Real;
Balance:Real;
Groceries:Real;
Water:Real;
Telephone:Real;
Electricity:Real;
Transport:Real;
Dependents:Integer;
Miscellaneous:Real;
CCBalance:Real;
CCInterest:Real;
TotalCCAmount:Real;
CCMonthlyPayments:Real;
BPrinciple:Real;
BLoanInterest:Real;
TotalBLoanAmount:Real;
BMonthlyPayments:Real;
CUPrinciple:Real;
CUInterest:Real;
TotalCULoanAmt:Real;
CUMonthlyPayments:Real;
TotalMonthlyRepayments:Real;
Sum:Integer;
BEGIN{MAIN}
FOR Applicant:=1 TO Max DO
BEGIN{FOR}
ApplicantName[Applicant]:='';
HousingCommunity[Applicant]:='';
ApplicantGrossSalary[Applicant]:=0;
ApplicantSalaryDeductions[Applicant]:=0;
ApplicantSpouse[Applicant]:='';
SpouseGrossSalary[Applicant]:=0;
SpouseSalaryDeductions[Applicant]:=0;
ApplicationStatus[Applicant]:='';
FinalApplicationStatus[Applicant]:='';
NetSalaries[Applicant]:=0;
ApplicantExpenses[Applicant]:=0;
ApplicantRepayments[Applicant]:=0;
FOR Applicant:=1 TO Max DO
BEGIN{FOR}
Write('What is the name of the applicant?');
Readln(Name);
ApplicantName[Applicant]:=Name;
Write('For which of the following housing communities are applications being made: "ClarkVillas", "BrentwoodGardens" or "SkyfallCourts"?');
Readln(Housing);
HousingCommunity[Applicant]:=Housing;
Write('What is the applicants gross salary?');
Readln(GSalary);
ApplicantGrossSalary[Applicant]:=GSalary;
Write('What are the applicants salary deductions?');
Readln(Deductions);
ApplicantSalaryDeductions[Applicant]:=Deductions;
Write('Does the applicant have a spouse?');
Readln(Spouse);
ApplicantSpouse[Applicant]:=Spouse;
IF Spouse='Yes' THEN
BEGIN{IF}
Write('What is the spouses gross salary?');
Readln(SpouseSalary);
SpouseGrossSalary[Applicant]:=SpouseSalary;
Write('What are the spouses salary deductions?');
Readln(SpouseDeductions);
SpouseSalaryDeductions[Applicant]:=SpouseDeductions;
BEGIN{ELSE}
SpouseSalary:=ZERO;
SpouseGrossSalary[Applicant]:=SpouseSalary;
SpouseDeductions:=ZERO;
SpouseSalaryDeductions[Applicant]:=SpouseDeductions;
FOR Applicant:=1 TO Max DO
BEGIN{FOR}
TotalGrossSalary:=ApplicantGrossSalary[Applicant]+SpouseGrossSalary[Applicant];
TotalSalaryDeductions:=ApplicantSalaryDeductions[Applicant]+SpouseSalaryDeductions[Applicant];
NetSalary:= TotalGrossSalary-TotalSalaryDeductions;
NetSalaries[Applicant]:=NetSalary;
FOR Applicant:=1 TO Max DO
BEGIN{FOR}
IF HousingCommunity[Applicant]='ClarkVillas' THEN
BEGIN{IF}
IF NetSalaries[Applicant]>QualifyClark THEN
BEGIN{IF}
Writeln('Qualified');
ApplicationStatus[Applicant]:=Positive;
Writeln('Not Qualified');
ApplicationStatus[Applicant]:=Negative;
IF HousingCommunity ='BrentWoodGardens' THEN
IF NetSalaries[Applicant]>QualifyBGarden THEN
Writeln('Qualified');
ApplicationStatus[Applicant]:=Positive; THEN
Writeln('Not Qualified');
ApplicationStatus[Applicant]:=Negative;
IF HousingCommunity[Applicant]:='SkyfallCourts' THEN
IF NetSalaries[Applicant]>QualifySkyfall THEN
Writeln('Qualified');
ApplicationStatus[Applicant]:=Positive; THEN
Writeln('Not Qualified');
ApplicationStatus[Applicant]:=Negative;
FOR Applicant:=1 TO Max DO
IF ApplicationStatus[Applicant]:=Postive THEN
Write('What is the principle loan Amount borrowed from the bank?');
Readln(BPrinciple);
Write('What is the outstanding balance on the credit card?');
Readln(CCBalance);
Write('What is the principle loan Amount borrowed from the credit union?');
Readln(CUPriniple);
BLoanInterest:=(BPrinciple*BTime*BRate)/100;
TotalBLoanAmt:=BLoanInterest+BPrinciple;
BMonthlyPayments:=TotalBLoanAmt/36;
CCInterest:=(CCBalance*CCTime*CCRate)/100;
TotalCCAmt:=CCInterest+CCBalance;
CCMonthlyPayents:=TotalCCAmt/18;
CUInterest:=(CUPrinciple*CUTime*CURate)/100;
TotalCULoanAmt:=CUInterest+CUPrinciple;
CCMonthlyPayments:=TotalCULoanAmt/36;
TotalMonthlyRepayments:= BMonthlyPayments + CCMonthlyPayments + CUMonthlyPayments;
ApplicantRepayments[Applicant]:=TotalMonthlyRepayments;
Write ('How much money is spent on groceries?');
Readln (Groceries);
Write ('What is the value of the water bill?');
Readln (Water);
Write ('What is the value of the electricity bill?');
Readln (Electricity);
Write ('What is the value of the telephone bill?');
Readln (Telephone);
Write ('How much money is spent on transport');
Readln (Transport);
Write ('How many dependents does the applicant have?');
Readln (Dependents);
Miscellaneous:= Dependents * DependentAllowance;
TotalExpenses:= Groceries + Water + Telephone + Electricity + Transport + Miscellaneous;
ApplicantExepenses:= TotalExpenses;
FOR Applicant:=1 TO Max DO
IF ApplicationStatus=Positive THEN
HalfNetSalary:=NetSalaries[Applicant]*Half;
Balance:=NetSalaries[Applicant] - (ApplicantRepayments[Applicant] + ApplicantExpenses[Applicant]);
IF Balance>HalfNetSalaries THEN
Writeln ('Approved');
FinalApplicationStatus[Applicant]:=CORRECT;
Sum:= Sum + 1; ELSE
Writeln('Not Approved');
FinalApplicationStatus[Applicant]:=WRONG;
Writeln('THE DETAILS FOR THE APPLICATIONS MADE ARE AS FOLLOWS:');
Writeln ('Application Details Applicant Information');
FOR Applicant:=1 TO Max DO
Writeln ('Name of Applicant: ', ApplicantName[Applicant]:25);
Writeln ('Housing Community: ', HousingCommunity[Applicant]:25);
Writeln ('Initial Application Status', ApplicationStatus[Applicant]:25);
Writeln ('Final Application Status ', FinalApplicationStatus[Applicant]:25);
Writeln ('A total of ', Sum,' applicants were approved for Housing.');
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
END.