If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Can Someone See What I've Done Wrong

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-03, 10:01
energy energy is offline
Registered User
 
Join Date: Apr 2003
Location: England
Posts: 12
Can Someone See What I've Done Wrong

PROGRAM PRO5(input,output);

USES crt;

VAR
score:real;
answer:char;

PROCEDURE Q_1;
BEGIN
repeat
writeln('What is the abbreviation for "fourth generation language"');
writeln('A 4GL');
writeln('B FGL');
writeln('C 4TH GL');
readln (answer);
answer:=upcase(answer);
until answer:= A OR B OR C;

If answer = B or C THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct')

score:= score + 1;

END;


PROCEDURE Q_2;
BEGIN
repeat
writeln('What two abbreviations are used for "bits per second"');
writeln('A baud rate + bps');
writeln('B bps + byte');
writeln('C bit + baud rate');
readln (answer);
answer:=upcase(answer);
until answer:= A OR B OR C;

If answer = B or C THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct')

score:= score + 1;

END;


PROCEDURE Q_3;
BEGIN
repeat
writeln('What abbreviation is used for "computer output on microfilm"');
writeln('A COM');
writeln('B COOM');
writeln('C COPOM');
readln (answer);
answer:=upcase(answer);
until answer:= A OR B OR C;

If answer = B or C THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct')

score:= score + 1;

END;

BEGIN
repeat

clrscr;

Q_1;
Q_2;
Q_3;
writeln('score = ' score 'out of 3');
readln;
score:=0
writeln('Do want to play again press Y for yes and N for no');
readln(answer);
readln;
UNTIL answer=<N>;
END.


I CAN'T GET PAST 1:1, I JUST CAN'T SEE IT PLEASE HELP
Reply With Quote
  #2 (permalink)  
Old 06-05-03, 04:02
msieben msieben is offline
Registered User
 
Join Date: Feb 2003
Location: Germany
Posts: 53
Re: Can Someone See What I've Done Wrong

Hi,

i don't know your compiler, but there seem to be a bunch of syntax errors. i fixed them so far for D6. Also i suggest to use a function for getting the user response:

Code:
PROGRAM PRO5(input,output);

// D6 syntax
// USES crt;
{$APPTYPE CONSOLE}


VAR
score:real;
answer:char;


function GetKey(validchars:string):char;
var key:char;
begin
  repeat
    readln(key);
    key:=upcase(key);
  until pos(key,validchars)>0;
  result:=key;
end;


PROCEDURE Q_1;
BEGIN
writeln('What is the abbreviation for "fourth generation language"');
writeln('A 4GL');
writeln('B FGL');
writeln('C 4TH GL');

Answer:=GetKey('ABC');

If (answer = 'B') or (answer='C') THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct');

score:= score + 1;

END;


PROCEDURE Q_2;
BEGIN
repeat
writeln('What two abbreviations are used for "bits per second"');
writeln('A baud rate + bps');
writeln('B bps + byte');
writeln('C bit + baud rate');
readln (answer);
answer:=upcase(answer);
until (answer= 'A') OR (answer='B') OR (answer='C');

If (answer = 'B') or (answer='C') THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct');

score:= score + 1;

END;


PROCEDURE Q_3;
BEGIN
repeat
writeln('What abbreviation is used for "computer output on microfilm"');
writeln('A COM');
writeln('B COOM');
writeln('C COPOM');
readln (answer);
answer:=upcase(answer);
until (answer= 'A') OR (answer='B') OR (answer='C');

If (answer = 'B') or (answer='C') THEN
writeln('Sorry you are incorrect')
ELSE
writeln('You are correct');

score:= score + 1;

END;

BEGIN
repeat

// clrscr;

Q_1;
Q_2;
Q_3;
writeln('score = ', score, 'out of 3');
readln;
score:=0;
writeln('Do want to play again press Y for yes and N for no');
readln(answer);
// readln;  ?? not really needed
answer:=upcase(answer);
UNTIL answer='N';
END.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On