Hello guys. I need for my homework to make a game, and i wanna do "who want to be a millionaire" but i donno much commands in pascal:| so .... i wanna be like reality>:) it's to hard? i dont think so...

## All 10 Replies

If you know nothing at all about Pascal then start learning with something simpler. Do you have a textbook for your course? If yes, then do all the exercises at the end of each chapter. They were put there for learning experience, not to just make the textbook thicker and more expensive.

``````program game;

uses crt;
var c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12: char;
r1, r2, r3, r4, r5, r6, r7, r8 ,r9, r10: char;
name, choose3: string;
Begin
while upcase(c1) <> 'N' do
Begin
writeln('Welcome to Who wants to be a millionaire. Whats your name?');
writeln('Are you ready Mrs ', name,'(Y/N)');
if c2 <> 'N' then
Begin
{here i want to make like 20 seconds to answer/question}
writeln('1. Who is the most inteligent?');
writeln('a. Abraham Licoln                              c. Albert Einstein');
writeln('b. Isaac Newton                                d. Blaise Pascal ');
{here i dont know, i want to show is this your final answer? and  wait 3 seconds and then show this}
if r1 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c3 = 'continue' then
Begin
writeln('2. ');
writeln('a.                                        c. ');
writeln('b.                                        d.  ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r2 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c4 = 'continue' then
Begin
writeln('3.  ');
writeln('a.                                             c. ');
writeln('b.                                             d. ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r3 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c5 = 'continue' then
Begin
writeln('4. ');
writeln('a.                                           c. ');
writeln('b.                                           d. ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r4 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c6 = 'continue' then
Begin
writeln('5. ');
writeln('a.                                             c. ');
writeln('b.                                             d. ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r5 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c7 = 'continue' then
Begin
writeln('6. ');
writeln('a.                                             c. ');
writeln('b.                                             d. ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r6 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c8 = 'continue' then
Begin
writeln('7. ');
writeln('a.                                        c. ');
writeln('b.                                        d.  ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r7 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c9 = 'continue' then
Begin
writeln('8. ');
writeln('a.                                             c.  ');
writeln('b.                                             d.  ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r8 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c10 = 'continue' then
Begin
writeln('9. ');
writeln('a.                                            c.  ');
writeln('b.                                            d.  ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r9 = 'd' then
Begin
writeln('Well Done!');
{here i want to wait 2 seconds}
writeln('You want to take the money or continue?');
if c12 = 'continue' then
Begin
writeln('10. ');
writeln('a.                                        c.  ');
writeln('b.                                        d.  ');
{show is this your final answer?(Y/N)  wait 3 seconds and then show this}
if r10 = 'd' then
writeln('Well Done!You Won')
else
writeln('You lost!');
end;
else writeln('You answered 9 question, well done');
end;
else writeln('The corect answer was', r9);
end;
else writeln('You answered 8 question, well done');
end;
else writeln('The corect answer was', r8);
end;
else writeln('You answered 7 question, well done');
end;
else writeln('The corect answer was', r7);
end;
else writeln('You answered 6 question, well done');
end;
else writeln('The corect answer was', r6);
end;
else writeln('You answered 5 question, well done');
end;
else writeln('The corect answer was', r5);
end;
else writeln('You answered 4 question, well done');
end;
else writeln('The corect answer was', r4);
end;
else writeln('You answered 3 question, well done');
end;
else writeln('The corect answer was', r3);
end;
else writeln('You answered 2 question, well done');
end;
else writeln('The corect answer was', r2);
end;
else writeln('You answered 1 question, well done');
end;
else writeln('The corect answer was', r1);
end;
else writeln('Goodbye');
writeln
writeln('Do you wanna play again? (Y/N)');
end;
end.``````

something like this...

...best would be to read random questions from a file. (file:text to vars and assign(filevar,'filesplace.txt'); and more...)
Other things: mrs should be deleted. Who knows who is playing? :-)
{here i want to make like 20 seconds to answer/question}: i think it's hard to make, but to count only if 20 seconds is OK: try dos unit in free pascal (google it)
{show is this your final answer?(Y/N) wait 3 seconds and then show this}: Maybe add "label" with Label moneyget; then write here a readln to a string and If (stringname='Y') or (stringname='y') then goto moneyget else begin and the code comes here (after that there needs to be an end; ).
And waitnig for n seconds is delay(n*1000);
If something is not OK, google it or ask somebody. :-)

-->...best would be to read random questions from a file. (file:text to vars and assign(filevar,'filesplace.txt'); and more...)

i'll make a folder named file.txt and then write questions in it?
and then what is the command in pascal because i dont understand in what u said...

-->Other things: mrs should be deleted. Who knows who is playing? :-)

yeah

-->{here i want to make like 20 seconds to answer/question}: i think it's hard to make, but to count only if 20 seconds is OK: try dos unit in free pascal (google it)

i cant find it, i tried but all i see is the real time, the year. and i cant see the timer, stop watch or what i was looking at...

-->{show is this your final answer?(Y/N) wait 3 seconds and then show this}: Maybe add "label" with Label moneyget; then write here a readln to a string and If (stringname='Y') or (stringname='y') then goto moneyget else begin and the code comes here (after that there needs to be an end; ).

can you explain what this command do?

-->And waitnig for n seconds is delay(n*1000);
it works:D

-->...best would be to read random questions from a file. (file:text to vars and assign(filevar,'filesplace.txt'); and more...)

i'll make a folder named file.txt and then write questions in it?
and then what is the command in pascal because i dont understand in what u said...
: No, a file named file.txt or file.anything. Not only txt works, but it's the best to edit.

-->{here i want to make like 20 seconds to answer/question}: i think it's hard to make, but to count only if 20 seconds is OK: try dos unit in free pascal (google it)

i cant find it, i tried but all i see is the real time, the year. and i cant see the timer, stop watch or what i was looking at...

: http://freepascal.org/docs-html/rtl/dos/sysinfo.html with GetDate and GetTime (there won't be a timer, sorry but you can get how long did answering took if copy these before and after reading question)

-->{show is this your final answer?(Y/N) wait 3 seconds and then show this}: Maybe add "label" with Label moneyget; then write here a readln to a string and If (stringname='Y') or (stringname='y') then goto moneyget else begin and the code comes here (after that there needs to be an end; ).

can you explain what this command do?

: So: paste BEFORE begin Label money; and when you wait for answer, you use if (readkey='y') or (readkey='Y') then goto money else begin and you pt the code there AND then put end; at the end. And where you put the codes after money get, put BEFORE money:

-->: No, a file named file.txt or file.anything. Not only txt works, but it's the best to edit.

i made a file.txt and there i wrote the questions with abcd
now in pascal what should i write? and where i write the correct answer?

-->: So: paste BEFORE begin Label money; and when you wait for answer, you use if (readkey='y') or (readkey='Y') then goto money else begin and you pt the code there AND then put end; at the end. And where you put the codes after money get, put BEFORE money

program haha;
uses crt;
var .....:.....

Label money;

Begin
the question
if (readkey='Y') then goto money
else
Begin
after money get....
i dont get it.. it's right?

->: No, a file named file.txt or file.anything. Not only txt works, but it's the best to edit.

i made a file.txt and there i wrote the questions with abcd
now in pascal what should i write? and where i write the correct answer?
:: Write like this:
Question One
A
Second
D
Third
B
Next
D
Again
C
...

-->: So: paste BEFORE begin Label money; and when you wait for answer, you use if (readkey='y') or (readkey='Y') then goto money else begin and you pt the code there AND then put end; at the end. And where you put the codes after money get, put BEFORE money

program haha;
uses crt;
var .....:.....

Label money;

Begin
the question
if (readkey='Y') then goto money
else
Begin
after money get....
i dont get it.. it's right?
::No!

``````program NAME;
uses crt;
var VARIABLES:HERE;
Label money:
Begin
{QUESTION COMMANDS}
if (readkey='Y') or (readkey='y') {y and Y, all the two} then goto money
else
Begin
{THINGS TO DO}
End;
money:
{OTHER THINGS}``````

And there are some other comments about your 1st code:
1: create a

``type t=array[1..10] of integer; var i,j,k:byte;  f:file; q:int; was:t; answer,correct:char; question:string; b:boolean;``

and you need to do these (not full code, just command):

``````assign(F,'FILE.TXT') //F=FILE.TXT
reset(F) //OPEN F
close(F) //CLOSE F AFTER ALL 10 QUESTIONS
for I:=1 to SOMETHING do begin //NOW ONLY ONE QUESTION AT A TIME, SHORTER AND PRETTIER CODE
randomize //to read a random question
SOMEVAR:=random(NUMBEROFQUESTIONS)+1
{YOU NEED TO PUT HERE SOMETHING TO GET THAT QUESTION WAS OR NOT}