anyone know qbasic here?
#2
REM PLEASE WRITE YOUR NAME HERE:........
REM THERE ARE NO MISTAKES IN COMMENTS.
REM THERE ARE NO MISTAKES IN VARIABLE NAMES.
REM ONLY HAND IN HAND WRITTEN CORRECTIONS ON THIS SHEET.
REM THERE ARE TEN MISTAKES TO FIND.
REM PUT A SINGLE LINE THROUGH THE CODING THAT IS WRONG.
REM WRITE THE CORRECT CODING IN THE BLANK LINE BELOW THE ERROR.
REM THE PROGRAM WILL PRINT OUT THE SUM (x+y) AND PRODUCT (x*y)
REM OF THE 25 PAIRS OF NUMBERS FROM 1 & 1 TO 5 & 5.
TOTAL = 0
LABEL:
CLS
INPUT "PLEASE PRESS S TO START OR X TO EXIT "; N$
IF ASC(N$) = 0 GOTO LABEL1 'WORK OUT THE LENGTH
DO WHILE UPPER(N$) <> "X" 'ONLY LOOP WHEN A NAME IS ENTERED I.E. MORE THAN 0 CHARACTERS ENTERED
FOR X = 1 TO 7 'FIRST LOOP
FOR Y = 1 TO 7 'SECOND LOOP
PRINT "x = "; X;
PRINT " Y = "; Y;
Z = X + Y
PRINT " X + Y = "; X + Y;
ZZ = X * Y
PRINT " X * Y = "; X * Y
TOTAL = TOTAL + ZZ
LOOP
NEXT X
NEXT Y
PRINT " TOTAL "
INPUT "PLEASE PRESS S TO START OR X TO EXIT"; N$
REM PLEASE WRITE DOWN THE VALUE OF "TOTAL" WHICH APPEARS ON SCREEN AT THE END OF THE PROGRAM
END
REM THERE ARE NO MISTAKES IN COMMENTS.
REM THERE ARE NO MISTAKES IN VARIABLE NAMES.
REM ONLY HAND IN HAND WRITTEN CORRECTIONS ON THIS SHEET.
REM THERE ARE TEN MISTAKES TO FIND.
REM PUT A SINGLE LINE THROUGH THE CODING THAT IS WRONG.
REM WRITE THE CORRECT CODING IN THE BLANK LINE BELOW THE ERROR.
REM THE PROGRAM WILL PRINT OUT THE SUM (x+y) AND PRODUCT (x*y)
REM OF THE 25 PAIRS OF NUMBERS FROM 1 & 1 TO 5 & 5.
TOTAL = 0
LABEL:
CLS
INPUT "PLEASE PRESS S TO START OR X TO EXIT "; N$
IF ASC(N$) = 0 GOTO LABEL1 'WORK OUT THE LENGTH
DO WHILE UPPER(N$) <> "X" 'ONLY LOOP WHEN A NAME IS ENTERED I.E. MORE THAN 0 CHARACTERS ENTERED
FOR X = 1 TO 7 'FIRST LOOP
FOR Y = 1 TO 7 'SECOND LOOP
PRINT "x = "; X;
PRINT " Y = "; Y;
Z = X + Y
PRINT " X + Y = "; X + Y;
ZZ = X * Y
PRINT " X * Y = "; X * Y
TOTAL = TOTAL + ZZ
LOOP
NEXT X
NEXT Y
PRINT " TOTAL "
INPUT "PLEASE PRESS S TO START OR X TO EXIT"; N$
REM PLEASE WRITE DOWN THE VALUE OF "TOTAL" WHICH APPEARS ON SCREEN AT THE END OF THE PROGRAM
END
#4
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
label: - Label1:
Upper = UCase$
Asc = Len
Edited cos paste didnt work..
and cos I wrote the wrong things...
[Edited by David_Wallis - 6/11/2002 2:20:27 PM]
[Edited by David_Wallis - 6/11/2002 2:43:31 PM]
Upper = UCase$
Asc = Len
Edited cos paste didnt work..
and cos I wrote the wrong things...
[Edited by David_Wallis - 6/11/2002 2:20:27 PM]
[Edited by David_Wallis - 6/11/2002 2:43:31 PM]
#5
Use to use qbasic a fair bit - If I wanted to do it I'd use...
Print "Press <S> to Start or <X> to Exit"
DO
x$ = ucase$(Inkey$ )
if x$ = "S" then gosub CodeHere
if x$ = "X" then Exit do
loop
Print "Prog Finished"
End
CodeHere:
REM Loops & Bollox
Return
[Edited by dsmith - 6/11/2002 4:12:05 PM]
Print "Press <S> to Start or <X> to Exit"
DO
x$ = ucase$(Inkey$ )
if x$ = "S" then gosub CodeHere
if x$ = "X" then Exit do
loop
Print "Prog Finished"
End
CodeHere:
REM Loops & Bollox
Return
[Edited by dsmith - 6/11/2002 4:12:05 PM]
Trending Topics
#12
difficult to point out specific errors but...
Label: should be Label1:
Asc(N$) should be Len(N$) - if comment is to be believed
Upper (N$) should be UCASE$(N$)
loops should be 1 to 5 not 1 to 7
Do line should be above the input line
no need then for last input line
next x and next y are thw rong way round
Its all abit sh*t really
Total will be (1 + 2 + 3 + 4 +5) + (2 + 4 + 6 + 8 + 10) etc..
[Edited by dsmith - 6/11/2002 2:33:19 PM]
Label: should be Label1:
Asc(N$) should be Len(N$) - if comment is to be believed
Upper (N$) should be UCASE$(N$)
loops should be 1 to 5 not 1 to 7
Do line should be above the input line
no need then for last input line
next x and next y are thw rong way round
Its all abit sh*t really
Total will be (1 + 2 + 3 + 4 +5) + (2 + 4 + 6 + 8 + 10) etc..
[Edited by dsmith - 6/11/2002 2:33:19 PM]
#15
'Press S to Start' but it only checks for 'X to Exit' and allows anything else input to start the calculation. Also it relies on INPUT which requires you to press RETURN (so it's not 'Press X to exit' really). Can't remember much BASIC (what I learnt was on a Speccy) but INKEY$ used to be a better bet.
Also it goes to the trouble of assigning X+Y to Z, and X*Y to ZZ, but then doesn't use them any more
Of course, this is clearly a coursework assignment so you shouldn't really be enlisting help.
[Edited by carl - 6/11/2002 3:18:20 PM]
Also it goes to the trouble of assigning X+Y to Z, and X*Y to ZZ, but then doesn't use them any more
Of course, this is clearly a coursework assignment so you shouldn't really be enlisting help.
[Edited by carl - 6/11/2002 3:18:20 PM]
Thread
Thread Starter
Forum
Replies
Last Post
djuk
Computer & Technology Related
3
25 February 2007 09:34 PM
john banks
Computer & Technology Related
3
01 July 2004 09:47 AM