Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I have no clue need help

IT_KidIT_Kid Posts: 4Member
Writing this program for a school project. It compiles and runs without error but the results are wrong and it goes inactive in the middle of the program. Could some kind soul help me plz and thanks.

Program Friends_For_Life;
Uses wincrt;
var
name : array[1..2] of string;
salary : array[1..2] of real;
occupation : array[1..2] of string;
Member_Total_Contribution : Array[1..2] of real;
x : integer;
Mission_Dues : Array[1..2] of real;
Membership_Dues : Array[1..2] of real;
Buildingfund : Array[1..2] of real;
Project_Hope : Array[1..2] of real;
Membership_Dues_Total : real;
Mission_Dues_Total : real;
Building_Fund_Total : real;
Project_Hope_Total : real;
Percentage : Array[1..2] of real;

Procedure Title;
Begin
Writeln('*******************************************************************************************************');
Writeln('');
Writeln(' FFL');
Writeln(' Friends For Life');
Writeln('');
Writeln('*******************************************************************************************************');
End;

Procedure Get_Data;
Begin
Title;
For x := 1 to 2 Do
Begin
Writeln('Enter member name');
Readln(name[x]);
Writeln('Enter member salary');
Readln(salary[x]);
Writeln('Enter member occupation');
Readln(occupation[x]);
clrscr;
Title;
End;
End;
Procedure Contribution_Calculation;
Begin
For x := 1 to 2 Do
Begin
Mission_Dues[x] := salary[x] * 0.015;
Membership_Dues[x] := salary[x] * 0.1;
Buildingfund[x] := salary[x] * 0.0125;
If occupation[x] = 'Doctor' Then
Begin
Project_Hope[x] := salary[x] * 0.05;
End
Else If occupation[x] = 'Lawyer' Then
Begin
Project_Hope[x] := salary[x] * 0.045;
End
Else If occupation[x] = 'Teacher' Then
Begin
Project_Hope[x] := salary[x] * 0.06;
End
Else
Begin
Project_Hope[x] := salary[x] * 0.03;
End;
End;
End;
Procedure Members_Total_Contribution;
Begin
For x := 1 to 2 Do
Begin
Member_Total_Contribution[x] := (Mission_Dues[x] + Membership_Dues[x] + Buildingfund[x] + Project_Hope[x]);
End;
End;
Procedure Total_For_Category;
Begin
Membership_Dues_Total := 0;
Mission_Dues_Total := 0;
Building_Fund_Total := 0;
Project_Hope_Total := 0;
For x := 1 to 2 Do
Begin
Membership_Dues_Total := Membership_Dues_Total + Membership_Dues[x];
Mission_Dues_Total := Mission_Dues_Total + Mission_Dues[x];
Building_Fund_Total := Building_Fund_Total + BuildingFund[x];
Project_Hope_Total := Project_Hope_Total + Project_Hope[x];
End;
End;
Procedure Contribution_Percentage;
var
Overall_Contribution : real;
Begin
Overall_Contribution :=0.01;
For x := 1 to 2 Do
Begin
Overall_Contribution := Overall_Contribution + Member_Total_contribution[x];
End;
For x := 1 to 2 Do
Begin
Percentage[x] := (Member_Total_contribution[x] / Overall_Contribution) *100;
End;
End;
Procedure Search_results;
Begin
Writeln('***********************************************************************');
Writeln(' Search results');
Writeln('***********************************************************************');
End;
Procedure Search;
var
Found : boolean;
index : integer;
Search_value : string;
max : integer;
Begin
found := false;
max := 2;
index := 1;
Writeln('Enter the name of person you wish to search for');
Readln(Search_value);
While (found = false) and (index<max) Do
Begin
If name[index] = Search_value then
Begin
Found := true;
End
Else
Begin
index := index + 1;
End;
End;
Search_results;
If Found = true then
Begin
Writeln('The person searched for is ',name[index]);
Writeln('Thier total contribution is $',Member_Total_contribution[index]:2:2);
End
Else
Begin
Writeln('Person not found');
End;
Readln;
clrscr;
Title;
End;
Procedure Total_Display;
Begin
Writeln('*****************************************************************************');
Writeln(' Member Contribution');
Writeln('*****************************************************************************');
End;
Procedure Category_Total_Display;
Begin
Writeln('*****************************************************************************');
Writeln(' Category Total');
Writeln('*****************************************************************************');
End;
Procedure Percentage_Display;
Begin
Writeln('*****************************************************************************');
Writeln(' Percentage Contribution');
Writeln('*****************************************************************************');
End;
Procedure Display;
Begin
Total_Display;
For x := 1 to 2 Do
Begin
Writeln(name[x]);
Writeln('Total contribution is $',Member_Total_contribution[x]:2:2);
End;
clrscr;
Title;
Category_Total_Display;
Writeln('Total Membership Dues is $',Membership_Dues_Total:2:2);
Writeln('Total Mission Dues is $',Mission_Dues_Total:2:2);
Writeln('Total Building Fund contibution is $',Building_Fund_Total:2:2);
Writeln('Total Project Hope contibution is $',Project_Hope_Total:2:2);
clrscr;
Title;
Percentage_Display;
For x := 1 to 2 Do
Begin
Writeln('Percentage contribution ',percentage[x]:2:2,'%');
End;
End;
Begin
Get_Data;
Members_Total_Contribution;
Total_For_Category;
Contribution_Percentage;
display;
Search;
Readln;
End.
I'm assuming the intended function will be obvious to others. I think you might have to run it to see the problem.
Sign In or Register to comment.