Programming 2 BASIC Programming ContentObjective Learn BASIC programming

  • Slides: 21
Download presentation
Programming 2 BASIC Programming Content-Objective: Learn BASIC programming entry skills. Language-Objective: Create a BASIC

Programming 2 BASIC Programming Content-Objective: Learn BASIC programming entry skills. Language-Objective: Create a BASIC program from scratch using JUST BASIC.

Programming 2 BASIC Programming Utah State Robotics 1 Standard 3 Common Core High School

Programming 2 BASIC Programming Utah State Robotics 1 Standard 3 Common Core High School Algebra Reasoning Common Core High School Interpreting Functions

Do today’s Starter Quiz! (in Canvas)

Do today’s Starter Quiz! (in Canvas)

Starter Information DEFINITIONS General Programming Language Categories (1) High level (plain language) (2) Machine

Starter Information DEFINITIONS General Programming Language Categories (1) High level (plain language) (2) Machine Level (binary)

KEY DEFINITIONS All computers at the core are programmed in: Machine code also known

KEY DEFINITIONS All computers at the core are programmed in: Machine code also known as binary

PROGRAM STRUCTURE TYPES 1. Sequential (instruction performed in a set order) 2. Object Oriented:

PROGRAM STRUCTURE TYPES 1. Sequential (instruction performed in a set order) 2. Object Oriented: (instructions are focused on a screen object state) 3. Low level (Machine code/binary) programming is always sequential.

Assembly Code: An Intermediate level language Assembly code programming uses a simple set of

Assembly Code: An Intermediate level language Assembly code programming uses a simple set of characters to represent the binary (example: 010110010) code. While not a high level language it does make machine level programming much easier.

High Level Programming Languages High level programming languages are written in PLAIN ENGLISH.

High Level Programming Languages High level programming languages are written in PLAIN ENGLISH.

High Level Language Structures Sequential (instruction performed in a set order) or Object Oriented:

High Level Language Structures Sequential (instruction performed in a set order) or Object Oriented: (instructions are focused on a screen object state) Programming languages prior to the 1990 tend to be sequential Languages newer than 1990 tend to be Object oriented

High Level Language Structures Continued Sequential instruction languages must be performed in a set

High Level Language Structures Continued Sequential instruction languages must be performed in a set order. Object Oriented languages DONOT require instructions to be executed in a set order.

Windows Programs Microsoft Windows programs are written in OBJECT ORIENTED languages. END STARTER INFORMATION

Windows Programs Microsoft Windows programs are written in OBJECT ORIENTED languages. END STARTER INFORMATION

Todays Class Task Create a simple BASIC program using Just Basic v 1. 01

Todays Class Task Create a simple BASIC program using Just Basic v 1. 01

Just BASIC SCREEN

Just BASIC SCREEN

Just BASIC Information 1. Click on “File” then “new BASIC source file” to start

Just BASIC Information 1. Click on “File” then “new BASIC source file” to start entering program. 2. The white area of the screen below the menu bar is where you write your program. 3. All program commands must have a line number before them and numerically they must be in ascending (progressively higher) order as the program goes down the page.

BASIC COMMANDS 1. REM (Remark a program comment that is not displayed or executed)

BASIC COMMANDS 1. REM (Remark a program comment that is not displayed or executed) 2. CLS (Clear screen –removes screen information) 3. PRINT displays text between quote marks on computer screen 4. GOTO (reroutes program execution to statement number after GOTO) 5. INPUT (stops program execution and waits for operator to enter data) 6. IF, THEN, ELSE (program logic argument where program execution is determined by the logic state of an object)

EXAMPLE BASIC PROGRAM 0 REM 10 CLS 20 X=0 30 WHILE X = 0

EXAMPLE BASIC PROGRAM 0 REM 10 CLS 20 X=0 30 WHILE X = 0 40 PRINT “Input your name “ 50 INPUT Y$ 60 IF Y$ = “” THEN 70 GOTO 20 80 ELSE 90 PRINT “My name is “; Y$ 100 END IF 110 X = X + 1 120 WEND 130 END

Program Execution Click on the “RUN” command on the top line of Just BASIC

Program Execution Click on the “RUN” command on the top line of Just BASIC window

Class Task 1 Copy the simple BASIC program and get it to work in

Class Task 1 Copy the simple BASIC program and get it to work in QBASIC 0 REM 10 CLS 20 X=0 30 WHILE X = 0 40 PRINT “Input your name “ 50 INPUT Y$ 60 IF Y$ = “” THEN 70 GOTO 20 80 ELSE 90 PRINT “My name is “; Y$ 100 END IF 110 X = X + 1 120 WEND 130 END

Class Task 2 After getting the simple BASIC program to work in Just-BASIC modify

Class Task 2 After getting the simple BASIC program to work in Just-BASIC modify it to ask for and display your hobby in addition to your name 0 REM 10 CLS 20 X=0 30 WHILE X = 0 40 PRINT “Input your name “ 50 INPUT Y$ 60 IF Y$ = “” THEN 70 GOTO 20 80 ELSE 90 PRINT “My name is “; Y$ 100 END IF 110 X = X + 1 120 WEND 130 END

Class Task 2 Continued To get it to ask for and display your hobby

Class Task 2 Continued To get it to ask for and display your hobby in addition to your name duplicate the statements highlighted in RED changing the variable from X to T, the PRINT from Input name to hobby and change Y$ to U$. 20 T=0 30 WHILE T = 0 40 PRINT “Input your hobby “ 50 INPUT U$ 60 IF U$ = “” THEN 70 GOTO 20 80 ELSE 90 PRINT “My hobby is “; U$ 100 END IF 110 T = T + 1 120 WEND

Class Task 2 Continued Place duplicated commands in program after statement 120 and number

Class Task 2 Continued Place duplicated commands in program after statement 120 and number your new commands starting at 130 and ending at 240. Change program END command number to 250 130 140 150 160 170 180 190 200 210 220 230 T=0 WHILE T= 0 PRINT “Input your hobby “ INPUT U$ IF U$ = “” THEN GOTO 130 ELSE PRINT “My hobby is “; U$ END IF T=T+1 WEND