1 / 13

TrueBASIC Ch 4 & 5 Sample Problems

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 < 10 THEN PRINT "Happy Meal" ELSEIF age < 18 PRINT "Ice Cream" ELSE THEN PRINT "Parfait" END IF.

ivory
Download Presentation

TrueBASIC Ch 4 & 5 Sample Problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 • Single line IF-ELSE must all be on one line • ELSEIF needs a THEN after condition • ELSE does not need a THEN • 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 • 2 • 4 • 5 • 6

  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 < m OR m <> z) PRINT "Error" END

  9. What are the errors? (4 total) DATA 12 READ x PRINT IF (x < 17 AND 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 < m OR m <> z) THEN PRINT "Error" END • “IS NOT” is not valid syntax in an IF condition • Single line IF-ELSE must all be on one line • Insufficient Data • 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

More Related