1 / 22

General Review

General Review. What have we done so far?. Variables , types of variables, defining variables INPUT statements READ and DATA statements PRINT and PRINT USING statements inbuilt functions - numerical and string. What YOU should have done!. To end Chapter 3 - Schneider 3.2; 3.3; 3.4; 3.5

Télécharger la présentation

General Review

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. General Review

  2. What have we done so far? • Variables , types of variables, defining variables • INPUT statements • READ and DATA statements • PRINT and PRINT USING statements • inbuilt functions - numerical and string

  3. What YOU should have done! • To end Chapter 3 - Schneider • 3.2; 3.3; 3.4; 3.5 • Try programming projects 1,2, & 6 p 94/5 • Prac work to end Week 5 • Modules 1-9 Study Book and questions at the end of the modules

  4. Testing • Does the program give correct results for typical conditions? • does it work for unusual conditions • very large or small entered values • zero entries • select a set of inputs for typical and extreme conditions, check by hand or calculator

  5. Debugging • A bug is a mistake in a program that prevents it from producing correct results • debugging is finding and correcting errors • three categories of errors: • syntax error • execution error, or runtime error • logic error

  6. Syntax error • a statement that does not follow the rules • typically a typing or spelling error • e.g. LOT instead of LET • z = x ** y • qbasic will find syntax errors for you • it will display an error message and highlight the portion of the incorrect statement • may not find all syntax errors until you run the program

  7. Logic errors • All statements are syntactically correct • qbasic can execute them and give results • results are wrong • errors in algorithm • hardest to find

  8. Execution error • or runtime error • syntax is correct but qbasic cannot execute that statement • x = 400 * 500 • overflow, value to large for data type • types of execturion errors • overflow • division by zero • type mismatch • illegal function call

  9. Problem • The period P of a pendulum of length L and maximum displacement angle  is given by the formula P = write a program that requests as input the length and maximum angle of displacement, and displays the period of the pendulum

  10. Plan • Output • period of pendulum • Input • length, angle (in degrees) • g = gravity • Process • convert degrees to radians • calculate period

  11. Plan • Input length • input angle in degrees • g = gravity constant • calculate period • print period and variables

  12. Valid read statements READ variables ---- DATA values e.g READ a, y, z DATA 10,20,30 READ x, y , z ---- DATA 10 DATA 20 DATA 30 READ and DATA

  13. READ X READ Y READ Z ----- DATA 10 DATA 20 DATA 30 READ X READ Y READ Z ----- DATA 10, 20, 30

  14. PRINT USING CLS a = 1 b = 4.2 c = 5328.268 d = 213 Fmt$ = “ ### ##.## ##,##.## ##” PRINT USING Fmt$; a; b; c; d

  15. a$ = “string” b$ = “very big string” c$ = “another string” Fmt$ = “\ 8 spaces\ \ 8 spaces \ ! &” PRINT USING Fmt$; a$; b$; a$; c$

  16. A = 150 b = 20.25 fmt1$ = “ $####.## $$####.##” PRINT USING fmt1$; a , b fmt2$ = “ Total sales this month $$###.##” PRINT USING fmt2$; b

  17. Other misconceptions • Pi is NOT predefined • pi = 22/7 • pi = 3.14… • pi = 4* ATN(1) • dimensioning variables • use DIM OR a suffix NOT both • DIM statements come at the beginning of a program • DIM a AS string, b AS long, c AS single

  18. Conventions in setting out programs • Title bar at start, name, date, program • list of all variables used and explanation • DIM statements for all variables • comments throughout • follow program development cycle • input, process, output

More Related