Jump to content

array now

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Simplistic

Simplistic

    Newbie

  • Members
  • Pip
  • 7 posts
ok so i had 1 problem with pascal already and i did it with your help after some time and i hope that you have enough patient to explain me the next one.
so this is the program i made:
program row;

program row;

var i,j,k,l:integer;

var n:string;

var number:  array [1..5] of integer;

var name: array [1..5] of string;

var money: array [1..5] of integer;

begin

name[1]:='jack       '; number[1]:=2235;    money[1]:=200;

name[2]:='sam        '; number[2]:=2231;    money[2]:=1400;

name[3]:='doe        '; number[3]:=8846;    money[3]:=-250;

name[4]:='alex       '; number[4]:=3124;    money[4]:=1000;

name[5]:='frank      '; number[5]:=0012;    money[5]:=10;


writeln ('input the number of the client');

readln (i);

writeln (name[i]);

writeln (number[i]);

writeln (money[i]);

readln;

end.


so the program asks for user to enter the number of the client and then it lists all the information about that client. now this was easy.
but my next task was to create the same program and same values but with this system:
program asks me to enter the NAME of the pearson, and then it lists number and money values of that pearson.
now i am pretty lost here because i always get the ''type mismatch error'' probably because i am mixing the string and integer values.
can you explain me how to finish this program?
thank you.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You need a for loop to go through the name array looking for a match. Use the match to print the desired information.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Simplistic

Simplistic

    Newbie

  • Members
  • Pip
  • 7 posts
all that i came up with is this:

Quote

writeln ('input the name of the client');
for i:=1 to 5 do
readln (name[i]);
writeln (number[i]);
writeln (money[i]);
readln;
end.

and it is not working, what to do?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The names are already loaded, why are you overwriting them?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog