hi im purely a beginner and im trying to write a program that will allow us to see graphically the number of people of every diferent age range in a given community then it should show the results graphically. i have done mostly all of the code and i just need help on displaying the results graphically. like this the stars need to be the number people. i need a procedure to add to my existing code so it will allow me to use stars to show the number of poeple in each age range.
example:
0-5 ***
6-11 ***
12-18 **
19-35 *****
36-55 *
56-65 *
66+ ****
this is my code.
im stuck on the write_age procedure. please help if u can >>>
program assignment2;
{$APPTYPE CONSOLE}
uses
SysUtils;
const population= 2;
type TpopRec = record
age:integer;
agerange: string
end;
Tperson = array[1..population] of TpopRec;
{PRE: true
POST: initialise the ages of all population}
procedure initialise_age(var ftn:Tperson);
var i:integer;
begin
for i:=1 to population do
begin
writeln('Introduce age of person ', i);
readln(ftn.age);
ftn.age:=0;
end;
end{initialise_age};
{PRE: true
POST: show the age ranges of all the population}
procedure write_age(ftn:Tperson);
var
i:integer;
begin
writeln('the ages are:');
for i:=1 to 7 do
writeln('0-5','age:',ftn.age);
end;
{PRE: ftn not empty}
{Post: Introduce ages for the population}
procedure intro_age(var ftn:Tperson);
var
i, age:integer;
begin
writeln('introduce the ages for the 10 people');
for i:=1 to 10 do
begin
read(age);
ftn.age:=age;
end;
end;
{PRE: and ftn is not empty
POST: average age for the population}
function average_age(ftn:Tperson):real;
var av:real;
std:integer;
begin
av:=0;
for std:=1 to population do
begin
av:=av+ftn[std].age;
end;
result:=av/population;
end;
{PRE: ftn is not empty
POST: maximum age}
function max_age(ftn:Tperson):integer;
var
maximum: integer;
i: integer;
begin
for i:=1 to population do
begin
if maximum < ftn.age then maximum:=ftn.age;
end;
result:=maximum;
end;
{PRE: ftn is not empty
POST: minimum age}
function min_age(ftn:Tperson):integer;
var
minimum: integer;
i: integer;
begin
for i:=1 to population do
begin
if minimum > ftn.age then minimum:=ftn.age;
end;
result:=minimum;
end;
{PRE: true
POST: menu with all the functionalities}
procedure menu(var ftn:Tperson; c:char);
begin
case c of
'r', 'R': intro_age(ftn);
'w','W': write_age(ftn);
'a','A': writeln('Average mark is: ',average_age(ftn));
'M': writeln('Maximum mark is: ', max_age(ftn));
'm': writeln('Minimum mark is: ', min_age(ftn));
else
writeln('error this option has not been recognised');
end;
end; {menu}
procedure prompts;
begin
writeln('Press r to introduce all the ages');
writeln('Press w to show all the ages');
writeln('Press a to calculate average age');
writeln('Press M to calculate maximum age');
writeln('Press m to calculate minumum age');
writeln('Press q to quit');
end;
var
FTN:Tperson;
choice:char;
begin
writeln('Welcome to population statistics');
initialise_age(ftn);
writeln ('You have the following options');
prompts;
readln(choice);
while (choice <> 'q') and (choice<> 'Q') do
begin
menu(FTN,choice);
prompts;
readln(choice);
end;
writeln('Bye...');
readln;
end.
its got a menu so when i press w it should show the diferent age ranges and stars next to it whioch indicate no of people which i cant do so please help if u can . thanks in advance for any help. greatly appreciated.