Presentation is loading. Please wait.

Presentation is loading. Please wait.

TrueBASIC Ch 4 & 5 Sample Problems. What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age <

Similar presentations


Presentation on theme: "TrueBASIC Ch 4 & 5 Sample Problems. What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age <"— Presentation transcript:

1 TrueBASIC Ch 4 & 5 Sample Problems

2 What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age < 10 THEN PRINT "Happy Meal" ELSEIF age < 18 PRINT "Ice Cream" ELSE THEN PRINT "Parfait" END IF

3 What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age < 10 THEN PRINT "Happy Meal" ELSEIF age < 18 THEN PRINT "Ice Cream" ELSE THEN PRINT "Parfait" END IF END 1.Single line IF-ELSE must all be on one line 2.ELSEIF needs a THEN after condition 3.ELSE does not need a THEN 4.Must have an END statement

4 What is the output? LET x = 10 LET y = 12 IF x > 12 - 10 / 10 THEN PRINT "1" IF x > (12 - 10) / 10 THEN PRINT "2" IF x > (12 - 10 / 10) THEN PRINT "3" IF NOT x > 10 THEN PRINT "4" IF x > y OR y > x THEN PRINT "5" IF NOT x > y OR NOT y > x THEN PRINT "6" END

5 What is the output? LET x = 10 LET y = 12 IF x > 12 - 10 / 10 THEN PRINT "1" IF x > (12 - 10) / 10 THEN PRINT "2" IF x > (12 - 10 / 10) THEN PRINT "3" IF NOT x > 10 THEN PRINT "4" IF x > y OR y > x THEN PRINT "5" IF NOT x > y OR NOT y > x THEN PRINT "6" END 24562456

6 What is the output? LET x = 14 SELECT CASE x CASE 10 TO 20, 25 TO 35 PRINT "A" CASE 10 TO 20 PRINT "B" CASE ELSE PRINT "C" END SELECT END

7 What is the output? LET x = 14 SELECT CASE x CASE 10 TO 20, 25 TO 35 PRINT "A" CASE 10 TO 20 PRINT "B" CASE ELSE PRINT "C" END SELECT END A

8 What are the errors? (4 total) DATA 12 READ x PRINT IF (x < 17 AND IS NOT 13) THEN PRINT "Okay" READ y IF (y > 8) THEN PRINT "Not Okay" ELSE PRINT "Really Bad" DATA 14, 15 READ z, m IF (z z) PRINT "Error" END

9 What are the errors? (4 total) DATA 12 READ x PRINT IF (x 13) THEN PRINT "Okay" READ y IF (y > 8) THEN PRINT "Not Okay " ELSE PRINT "Really Bad" DATA 14, 15, 16 READ z, m IF (z z) THEN PRINT "Error" END 1.“IS NOT” is not valid syntax in an IF condition 2.Single line IF-ELSE must all be on one line 3.Insufficient Data 4.IF statement must be followed by THEN

10 Write a One Line TrueBASIC Statement for each of the Following Commands Ask the user for his/her name Print winner when the team is Rutgers, otherwise print loser Calculate dollars spent as quantity times price

11 Write a One Line TrueBASIC Statement for each of the Following Commands Ask the user for his/her name INPUT PROMPT "What is your name? ": name$ Print winner when the team is Rutgers, otherwise print loser IF(team$ = "Rutgers") THEN PRINT "winner" ELSE PRINT "Loser" Calculate dollars spent as quantity times price LET dollars_spent = quantity * price

12 Write a One Line TrueBASIC Statement for each of the Following Commands Get data (not from user) for 3 car name variables Provide the values for 3 car names Display to the user the contents of the num variable, but put three tabs in front

13 Write a One Line TrueBASIC Statement for each of the Following Commands Get data (not from user) for 3 car name variables READ car1$, car2$, car3$ Provide the values for 3 car names DATA "Grand Prix", "Camaro", "Mustang" Display to the user the contents of the num variable, but put three tabs in front PRINT,,,num


Download ppt "TrueBASIC Ch 4 & 5 Sample Problems. What are the errors? (4 total) INPUT age IF age > 7 THEN PRINT "rollercoaster" ELSE PRINT "ferris wheel" IF age <"

Similar presentations


Ads by Google