Sample Code!
When you think of a computer class, most people think it is about learning how to use a computer - opening and saving files, word processing, surfing the internet, etc.
For this class, however, you are already expected to know those basics. Computer Math Online! is about making programs like word processors, games, etc.
That requires math - and lots of it! Below, you will see some examples of Visual Basic code that your high-schooler will be writing when they take this class...
Real-World Calculations:
This code is used to calculate material that is bought at a Fabric Store. The students have to write the formulas that will determine the subtotal, amount of tax and final cost. In Algebra, variables are usually one letter. In Visual Basic, you can see that variables (Subtotal, AmntOfYards, CostPerYard, etc.) are more like words that describe what is being calculated.
Subtotal = AmntOfYards * CostPerYard AmntOfTax = Subtotal * 0.05 Final Cost = Subtotal + AmntOfTax
Graphics:
The following code draws a red-filled circle wherever the user clicks on the screen. The variable "Rad" stands for the radius of the circle. "X" and "Y" are the coordinates for the center of the circle by using a coordinate plane similar to the one they learned in Algebra. This also incorporates a Loop, which tells the computer to repeat a task over and over again. In this case, 500 red circles are drawn, each one a tiny bit bigger than the last, and that makes it look like one filled circle.
For Rad = 1 To 500 Circle (X, Y), Rad, vbRed Next Rad
Working With Words:
Yes, math is even used when manipulating words, letters, and characters. It isn't just for numbers anymore! Can you guess what this code is supposed to do? Your student will know, after taking this course...
LenOfName = Len(PersonName) SpacePosition = InStr(1, PersonName, " ") LenOfLastName = LenOfName - SpacePosition
Computer Simulations and Experiments
A computer can simulate thousands of random rolls of a die and never get bored. Your student will be writing a program that does this experiment. Now, you may be thinking, who cares how many rolls it takes? Well, this is just the beginning of teaching programmers how to use the computer to generate random values and simulate experiments that would take too long in real life. Examples would include: population changes, traffic patterns, fingerprint analyses, etc.
Randomize If NumWanted >= 1 And NumWanted <= 6 And WantInARow > 0 Then Do While InARowSoFar <> WantInARow NumRolled = Int(6 * Rnd + 1) RollList.AddItem NumRolled Loop
|