Assignment Pascal !!
Been looking over the assignment and the tasks are very similar creating variables and asking the user questions.
The first thing I am going to do is create a plan of the basic program so I don’t have to guess how it is going to work, I will create the program on a note pad.
The program is going to enter the persons name, height and there shoe size. the last line of the program should say Richard you are 1.8m tall and wear size ten shoes.
The first thing is to declare what the program is called.
PROGRAM task3; USES CRT; VAR name:string; height:string; shoe:integer;
We have given the program a name of height, told the compiler that we are using a cathode ray tube to display the program and named are variables for the program, we are going to use. I would of liked to have used integer for height but because we are using the letter M we have to use string. Integer will be good for the shoe size because we are only entering a number.
BEGIN CLRSCR; WRITELN('What is your name ?'); READLN(name); CLRSCR;
What I have said: BEGIN the program, clear the screen, write the line what is your name?. The program is going to read the text that the user inputs for there name and store that name, then clear the screen ready for the next question, how tall are you.
WRITELN(name,' how tall are you in meters ? '); READLN(height); CLRSCR;
By putting the variable name before the question the program is already calling the person by their name. then CLRSCR ready for the next question.
WRITELN(name, ' what size feet do you take ?'); WRITELN('Please answer using numbers.'); READLN(shoe); CLRSCR; WRITELN(name,' you are ', height ,' and take size ', shoe ,' shoes.'); READLN; END.
What the last line is doing is taking all the stored variables and displaying them in the sentence for you to read. Variables are surrounded by commas and text to be displayed are in single quote marks. (don’t forget to leave spaces after the first quote mark or your text will all be joined together) ‘ text ‘ ,variable, ‘ text ‘,variable,’ and so on !!!!!!’. It should be displayed correctly if this pattern is followed.
Edit after trying the program,, I have changed the name of the PROGRAM (it was called height) you cannot have the same named program and variable in the same program.


One Response to “Assignment Pascal !!”
Access to H.E » Back to College said...
[...] documentation to support your program. I have already done one of the programs in my last Pascal posting. Which was to create your own program. What we will do is create the other two so they are [...]