Programming Graphs with Visual Basic

advertisement

Lesson Title : Programming Graphs with Visual Basic

Teacher : Kathleen Barrette kbarrette@mpsri.net

District/School : Middletown High School

Middletown

Grade Level : 9-12

Content Area : Visual Basic Programming

Time Allotment : Two weeks (5 class periods meeting for 80 minutes every other day)

Academic Standard(s)/Common Core of Learning Statement(s) addressed:

Applied Learning Standards

A1 Problem Solving: The student will address Applied Learning Standard A1a by designing and documenting a Visual Basic program.

Math Standards

Function and Algebra Concepts M3i, M3j, M3n : The student will be able to represent functional relationships in formulas, tables, and graphs and translate between pairs of these. The student will solve linear and quadratic equations symbolically, graphically, and numerically and know how to use the quadratic formula for solving quadratic equations. Student will use technology to represent and analyze functions and their graphs.

Mathematical Connections : Students have graphed equations in math class but this lesson requires that they transfer this knowledge to a programming problem. They must write the code to display the graph.

Technology Standards

Technology Productivity Tools : Students will use technology tools to enhance learning, increase productivity and promote creativity. Students construct technology-enhanced models.

Abstract: In these lessons students will use the knowledge of line and bar graphs they have acquired in mathematics class and the programming skills they have developed in

VB to write programs that will display information entered by the user in various graphical formats. Students will demonstrate their understanding of the relationship between screen coordinates and graph coordinates.

Goal : To give students the opportunity to design and write programs exploring mathematical concepts.

Performance Indicators :

• The student will demonstrate an understanding of the graphical methods available in Visual Basic.

• The student will demonstrate the connection of mathematics to their study of programming.

• The student will demonstrate good programming practices.

• The student will provide evidence of good planning and implementation of steps necessary to create the program.

Materials : Textbook

Assignments with rubrics

Technology : Computer and printer

Software - VB 6.0, word processing and Internet access.

Instructional Procedure :

Introduction:

Instruction on graphical methods in Visual Basic

Discussion of scale factors in graphs

Activities:

Program #1 - Line Graph Program

Modifications to Program #1 – The Bar Graph Program

Program #2 - Linear Equation Program

Closure:

Self-assessment

Peer-assessment

Assessment :

IPO

Chart

Flowchart

Accommodations/Modifications :

Allow students extra time after school.

Extensions : Students can add the functionality of graphing a quadratic equation or higher level poynomial.

Reflection : Students in peer reviews.

Connection to Other Content Areas : Mathematics

Business/Community Partners : Information Technology

The Line Graph Program

Write a program that allows the user to enter a test number and a test score (up to 10 pairs of numbers), displays the pairs of numbers in a list box and graphs the ordered pairs in a picture box. The program should contain four command buttons; Enter Data, Graph,

Clear and Exit. The Enter Data command button should store the numbers in the arrays and display them in a list box. It should also keep track of how many pairs of numbers are entered. The Graph command button should display the x and y axis and the horizontal guidelines, and graph the ordered pairs which are stored in the arrays. The clear button should clear the text boxes, the list box, the picture box and set the counter back to zero.

Once you have the program working, add the following features:

• Code the KeyPress Event for each text box. The first key press event should move the focus to the second text box and the second text box’s key press event should call the cmdEnterData_Click event procedure and set the focus to either the graph button or the first text box depending on whether the counter is less than 10 or not.

• Code the cmdEnterData_Click so that it displays a message “The arrays are full!” when the counter reaches 10. If the counter is reaches 10 the focus should be set to the graph button.

Please run the executable version of this program to get a feel for how the focus should be set.

Once you have this program completed and reviewed by another student, call me over for the final review.

Modify your program #1 to display a bar graph instead of a line graph. See prjBarGraph.exe in the Concept 4 folder and video layout below. Note: Each bar should display in a different color.

The Linear Equation Solver (The prjLinearEquation.exe is in the Concept 4 Folder please run the program to get a feel for how it should execute.)

Write a program to solve and graph a linear equation whose coefficients are entered in text boxes.

The standard form of a linear equation is: ax + b = c

The solution to the equation (the X intercept) is x = (c-b)/a (There is no X intercept if a=0)

The equation to graph is y = ax + b – c (Display and graph)

Note:

1.

Code KeyPress

Event for text boxes.

2.

Draw hash marks on axes.

3.

Label axes.

4.

Display the simplified equation.

5.

Display the x and y intercepts and the slope in a frame.

Criteria

Program Documentation

• IPO

• TOE

• Flowchart

Code Documentation

• Name

• Program ID

• Internal in each Event

Procedure

Program Code

• Required Event Procedures have been coded & execute correctly

• Output Correct and Formatted appropriately

User Friendly Interface

• No Spelling Errors

• Access Keys and/or Control

Keys

• Tab Key moves through the form appropriately

• Title on title bar

• Objects aligned appropriately and positioned logically

• Initials on the form

• Form is self explanatory

• Appropriate spacing is used in output

• Appropriate labels and messages are used

• Axes are labeled and have hash marks

• Simplified equation is displayed

• Enter key moves focus from one text box to the next

Variables

• Declared in correct location

• Declared with appropriate type

Code Indentation

• Event Procedures

• Within Loops/If-Then-

Self Peer Teacher

Notes

Teacher

Evaluation

(Possible

Points)

(15)

(3)

(20)

(16)

(2)

(2)

Else/Select Case

Housekeeping

• No unnecessary or redundant code

• Empty and/or unused event procedures are deleted

Total Points

N/A

Student Grade (Total Points/60)

N/A N/A

N/A N/A

N/A

(2)

____ out of

60

Download