Back to DFS's Pascal Page


Pascal Madlib Problem III

Using Procedures & Parameters

Herman's maître d' says, "Me and the boys were trying to guess how you spell your name." Obviously, he has some grammar and sequencing problems. To help him out, you have two jobs to do.

Be creative!!! Your fellow students will have an opportunity to do your madlib during the next class.

program Madlib(input, output);

procedure greeting(var newname : string);
 begin
  write('Hello, what is your name? ');
  readln(newname);
  writeln;
  writeln('I hope you enjoy madlibs, ', newname:0, '.')
 end; {procedure greeting}

procedure choices( name : string; var newnoun, newplace, newnumber, newliquid : string);
 begin
  writeln('Please choose your words.');
  writeln('Try to pick funny words, ', name:0, '.');
  writeln;
  write('Type a noun which is a thing. ');
  readln(newnoun);
  write('Type your least favorite city or country. ');
  readln(newplace);
  write('Type a number. ');
  readln(newnumber);
  write('Type a liquid. ');
  readln(newliquid)
 end; {procedure choices}

procedure printlaw(noun, place, number, liquid : string);
 begin
  writeln;
  writeln('It will be unlawful to own a ', noun:0);
  writeln('or to carry a concealed ', noun:0);
  writeln('without a ', noun:0, ' license.');
  writeln('The penalty for ', noun:0, '-carrying');
  writeln('will be thirty days in ', place:0);
  writeln('or a fine of ', number:0, ' dollars.');
  writeln('The penalty is double if the person');
  writeln('is arrested while under the influence');
  writeln('of ', liquid:0, '.')
 end; {procedure printlaw}

procedure thanks(name : string);
 begin
  writeln;
  write('I hope you liked your new law, ');
  writeln(name:0, '.');
  writeln;
  writeln('Thank you for using my madlib.')
 end; {procedure thanks}

var
  uname, noun, place, number, liquid: string;

begin {main}
 greeting(uname);
 choices(uname, noun, place, number, liquid);
 printlaw(noun, place, number, liquid);
 thanks(uname);
 readln
end.

© 1997-99 DFStermole
Created 16 Dec 97
HTMLified 31 Dec 99