1 / 7

SEQUENCE STRUCTURE FLOWCHART & PROGRAM

SEQUENCE STRUCTURE FLOWCHART & PROGRAM. A. Inserts and line edits for Sequence Program 60 LET R=3:C=10 310 LOCATE R,C:PRINT Head1$ 312 R=R+1 320 LOCATE R,C:PRINT Head2$ 322 R=R+1 330 LOCATE R,C:PRINT Head3$. 1000 10 REM This is a sequence program. It will create the

tana
Download Presentation

SEQUENCE STRUCTURE FLOWCHART & PROGRAM

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. SEQUENCE STRUCTURE FLOWCHART & PROGRAM A. Inserts and line edits for Sequence Program 60 LET R=3:C=10 310 LOCATE R,C:PRINT Head1$ 312 R=R+1 320 LOCATE R,C:PRINT Head2$ 322 R=R+1 330 LOCATE R,C:PRINT Head3$ 1000 10 REM This is a sequence program. It will create the ‘ computer heading then print it out. It is program #2 on ‘ the list of ten QBASIC Programs. This is a very small ‘ program, it has less than 100 lines of code. This part of the ‘ program will create the computer heading. It is called ‘ the “Initialization or Housekeeping Routine” because ‘ this is were all fields needed to run the program are ‘ created and given value. 30 LET Head1$=“Last, First” 40 LET Head2$=“Class Period - Student’s Grade” 50 LET Head3$=“MM/DD/YY” 2000 200 REM This statement setups up the screen background and text color. 20 COLOR 5,2:CLS 3000 300 REM This part of the program will print out the ‘ computer Heading. It is called the Main Process ‘ Routine, because all manipulations, calculations, and ‘ display of information are performed in this section 310 PRINT Head1$ 320 PRINT Head2$ 330 PRINT Head3$ 4000 END B.Inserts and line edits for Sequence Program 70 LET Title1$=“SEQUENCE PROGRAM” 80 LET TitSub$=“ Computer Heading” 332 R=R+3 340 LOCATE R,C:PRINT Title1$ 342 R=R+1 350 LOCATE R,C:PRINT Titsub$ 352 R=R+2 • C. Reflections Questions: • How many field names were created in section 1000? List each one. • What action does the command “CLS” perform? • In section 3000, give an example of what data will be printed.

  2. LOOPING STRUCTURE FLOWCHART & PROGRAM A. Inserts and line edits for Looping Program 20 LET Cb=0:Ct=1 22 COLOR Cb,Ct:CLS 40 LET Ntimes=15 310 FOR Ctr = 1 TO Ntimes 320 PRINT Ctr;”.” 322 Cb=Cb+1:Ct=Ct+1 330 NEXT Ctr 1000 10 REM This is a Looping program. It will create a ‘ number counter then print it out. It is program #4 on ‘ the list of ten QBASIC Programs. This is a very small ‘ program, it has less than 100 lines of code. This part of the ‘ program will create the counter field “Ctr” and set its’ value to ‘ equal zero. Number fields do not have a “$” at the end of ‘ them. This part of the program is called the “Initialization or ‘ Housekeeping Routine” because this is were all fields ‘ needed to run the program are created and given value. 20 COLOR 5,2:CLS 30 LET Ctr=0 40 LET Ntimes=9 2000 200 REM This statement setups up the screen background and text color. 3000 300 REM This part of the program will print out the ‘ counter. It is called the Main Process Routine, ‘ because all manipulations, calculations, and ‘ display of information are performed in this section 310 FOR Ctr = 1 TO Ntimes 320 PRINT Ctr;”.” 330 NEXT Ctr 4000 END B. Inserts and line edits for Looping Program 40 LET Ntimes=999999 310 FOR Ctr = 1 TO Ntimes 320 LOCATE 10,20:PRINT Ctr 330 NEXT Ctr • C. Reflections Questions: • How many times is the counter referred to in section 3000? • What Color background are numbers: 1,3,5, and 7? • In program “B”, Why does the numbers print in the same position?

  3. R DATA Statements 5000 S S Yes ? “EOF” No No Yes Code =? R SELECTION STRUCTURE FLOWCHART & PROGRAM 1000 10 REM This is a selection program. It will create data statements to be processed by the READ command. Then it will print it out data that has a specific code. It is program #3 on the list of ten QBASIC Programs ‘.This is a very small program, it has less than 100 lines of code. This part of the program will create 24 records. Each record will have two field “Code” and “Description”. Each field is separated with a comma, “,”. Because both field contain text data, the field names will have a “$” at ‘ the end. This part of the program is called the “Input Data” because this is where all data needed to run the program will be created 3000 300 REM This part of the program will print out the ‘ counter. It is called the Main Process Routine, ‘ because all manipulations, calculations, and ‘ display of information are performed in this section 310 READ Code$, Description$ 320 IF Code$ = “EOF” then End If code$=“CHP” OR Code$=“TOC Then PRINT Code$, Description$ else 330 GOTO 310 5000 510 DATA “CHP “,”Motherboard“ 520 DATA “CHP “,”Central Processing Unit“ 530 DATA “CHP “,”Random Access Memory“ 540 DATA “CHP “,”Read Only Memory“ 550 DATA “TOC”,”Desktop“ 560 DATA “TOC”,”Tower “ 570 DATA “TOC”,”Laptop“ 590 DATA “TOC”,”Notebook “ (insert more data statements here) 5999 DATA “EOF”,”End of File“ • C. Reflections Questions: • How many questions are asked in this program? What are they? • In section 5000, Name two possible codes that the computer can test for? • Will the last data statement be printed?

  4. DATA Statements 5000 SELECTION STRUCTURE FLOWCHART & PROGRAM 1000 10 REM This is a selection program. It will create data statements to be processed by the READ command. Then it will print it out data that has a specific code. It is program #3 on the list of ten QBASIC Programs ‘.This is a very small program, it has less than 100 lines of code. This part of the program will create 24 records. Each record will have two field “Code” and “Description”. Each field is separated with a comma, “,”. Because both field contain text data, the field names will have a “$” at ‘ the end. This part of the program is called the “Input Data” because this is where all data needed to run the program will be created 3000 300 REM This part of the program will print out the ‘ counter. It is called the Main Process Routine, ‘ because all manipulations, calculations, and ‘ display of information are performed in this section 310 READ Code$, Description$ 320 IF Code$ = “EOF” then End 330 GOTO off page connect #2 N 5000 510 DATA “CHP “,”Motherboard“ 520 DATA “CHP “,”Central Processing Unit“ 530 DATA “CHP “,”Random Access Memory“ 540 DATA “CHP “,”Read Only Memory“ 550 DATA “TOC”,”Desktop“ 560 DATA “TOC”,”Tower “ 570 DATA “TOC”,”Laptop“ 590 DATA “TOC”,”Notebook “ (insert more data statements here) 5999 DATA “EOF”,”End of File“ PG#1 S ? “EOF” No PG#2 N Yes

  5. p PG#2 N ? Code= “TOC” No Yes Write a Line No ? Code= “INP” Yes Message = “Code Correct” PG#1 S ? Code= “CHP” Message = “Code Correct” Yes No Message = “Code Correct” Message Code Error p NESTED IF-THEN-ELSE STRUCTURE FLOWCHART & PROGRAM 3000 300 REM This part of the program will select codes TOC, INP, and CHP to be printed out. The message “Code is Correct”. If any other codes are read, the message will read “Code Error”. This is a nested if-then-else structure because multiple questions are asked to determine if the code meets the criteria. ‘ display of information are performed in this section 330 IF Code$=“TOC” Then Message$=“Code Correct” ESLE IF Code$=“INP” Then Message$=“Code Correct” ELSE IF Code$=“CHP” Then Message$=“Code Correct” ELSE Message$=“Code Error” END IF 330 PRINT Code$, Description$, Message$ 330 GOTO off page connect #2 N

  6. HOUSEKEEPING ROUTINE 1000 BORDER/ WELCOME ROUTINE 2000 MAIN PROCESS ROUTINE 3000 FINAL ROUTINE 4000 MAIN PROCESS STRUCTURE FLOWCHART & PROGRAM 100 REM *******PROGRAM CONTROL******** GOSUB 1000 GOSUB 2000 GOSUB 3000 GOSUB 4000 199 END 1000 REM ******* HOUSEKEEPING ROUTINE *************** 1990 REM ******* HOUSEKEEPING ROUTINE *************** 1999 RETURN 2000 REM ******* BORDER/WELCOME ROUTINE *************** 2990 REM ******* END BORDER/WELCOME ROUTINE *************** 2999 RETURN 3000 REM ******* MAIN PROCESS ROUTINE *************** 3100 READ Code$, Description$ IF Code$ = “EOF” then End IF Code$=“TOC” Then Message$=“Code Correct” ESLE IF Code$=“INP” Then Message$=“Code Correct” ELSE IF Code$=“CHP” Then Message$=“Code Correct” ELSE Message$=“Code Error” END IF PRINT Code$, Description$, Message$ GOTO 3100 3990 REM *******END MAIN PROCESS ROUTINE *************** 3999 RETURN 4000 1000 REM ******* FINAL ROUTINE *************** 41990 REM ******* END FINAL ROUTINE *************** 4999 RETURN 5000 REM *********************INPUT DATA************************** 510 DATA “CHP “,”Motherboard“ 520 DATA “CHP “,”Central Processing Unit“ 530 DATA “CHP “,”Random Access Memory“ 540 DATA “CHP “,”Read Only Memory“ 550 DATA “TOC”,”Desktop“ 560 DATA “TOC”,”Tower “ 570 DATA “TOC”,”Laptop“ 590 DATA “TOC”,”Notebook “ (insert more data statements here) 5999 DATA “EOF”,”End of File“

  7. SEQUENCE STRUCTURE FLOWCHART

More Related