Professional Documents
Culture Documents
Pascal
Problem Solving
Phase
Defining Diagram
INPUT PROCESSING OUTPUT
House Names: House_funds $140,000 Total_points
house[i] i 1 to 4 low_house_nam
House points: Read house[i] e
points [i] Read points[i] low_house_poin
Calculate total points ts
Total_points points[i]+ high_house_na
Total_points me
Determine the house with the high_house_poi
highest and lowest points nts
Calculate funds for the house high_house_fun
with the highest and lowest ds
points low_house_fun
low_house_funds 17% of ds
House_funds
high_house_funds 45% of
House_funds
Print Total_points
Print House name, points and
house funds
{This algorithm accepts the names and points scored for each house,
calculates the total points amassed, determines the house with the house and
lowest points, calculates the percentage of funds that go to the houses with the
highest and lowest points, outputs the total points scored and the names and
points of the two houses and the respective amounts earned.}
Var
house: array[1..4]of string { Declaration of arrays}
points: array[1..4]of integer
Total_points: integer {Declaration of variables}
i: integer
low_house_points, high_house_points: integer
high_house_name, low_house_name: integer
high_house_funds, low_house_funds, house_funds: real
START
high_house_funds 0 {Initializing of variables}
low_house_funds 0
high_house_points 0
low_house_points 9999 {Variable initialized to value greater
than house
Total_points 0 points}
house_funds $140,000 {Variable initialized to value of house
fund}
high_house_name
low_house_name
Print Enter house name {Prompts user to enter house name into
the array}
read house [i]
Print Enter points scored by house {Prompts user to enter points
scored
read points [i] by each house into the array}
Endwhile
Total_points points[i] + Total_points {Calculating the total points
amassed}
If points[i] > high_house_points Then {This IF statement works out
the house
high_house_points points[i] with the highest points }
high_house_house house[i]
Endif
{This algorithm accepts the names and points scored for each house, calculates the total points
amassed, determines the house with the house and lowest points, calculates the percentage of funds
that go to the houses with the highest and lowest points, outputs the total points scored and the
names and points of the two houses and the respective amounts earned.}
Var
BEGIN
high_house_funds:=0;
low_house_funds:=0;
high_house_points:=0;
low_house_points:=9999;
Total_points:=0;
house_funds:=140000;
high_house_name:='';
low_house_name:='';
For i:=1 to 4 DO
house[i]:='';
points[i]:=0;
For i:=1 to 4 DO
BEGIN
END.