home

=Computer Programming I (VB) CS602 Periods 2 & 5=

Friday December 3, 2010
//Objective: Write programs that use the random number generator.//

The assignment statement in VB for getting a random number from 0 to 44 is __Paper and Pencil:__ Work with a partner if desired. 1. How many integers are there from 0 to 10 including 0 and 10? 2. How many integers are there from 0 to 1? 3. How many integers are there from 0 to 2? 4. Write an assignment statement in VB for a random number from 0 to 10? 5. Write an assignment statementin VB for a random number from 0 to n? 6. Write an assignment statementin VB for a random number from 10 to 20? 7. Write an assignment statementin VB for a random number from 11 to 20? 8. Write an assignment statementin VB for a random number from x to y?
 * Dim Number As Integer ** is the declaration.
 * Number = 44 * Rnd **

__Finish__ __Program:__ **MyRandom.frm** //If there is still time left in the period, embellish the program by including something like, Trim, If Then, If Then Else, or having the user pick the first number in the range also.// Do a self-evaluation with the quality check off sheet. Have Miss Hangen check it. __New Program:__ **FlipCoin.frm** or **FlipCoin.sb**

 Upload programs to your Gaggle digital locker.

Thursday December 2, 2010
//Objective: Write programs that use the random number generator.//

Get into Gaggle and save your **RandomFun.sb** Scratch program to your desktop. Test it. __Paper and Pencil:__ Explain what your program does and how it uses random numbers. Have Miss Hangen check your program.

__Finish__ __Program:__ **MyRandom.frm** //If there is still time left in the period, embellish the program by including something like, Trim, If Then, If Then Else, or having the user pick the first number in the range also.// Do a self-evaluation with the quality check off sheet. Have Miss Hangen check it.

 Upload programs to your Gaggle digital locker.

Wednesday December 1, 2010
//Objective: Write programs that use the random number generator.//



Get into your Gaggle digital locker and save your RandomNumber.frm program to your desktop.

Write the answers on paper and keep it for later in the period when you write your own program.

1. When you run your RandomNumber.frm program, do you get the same exact results as the example shown on the direction sheet?

2. Why or why not?

3. What line in the code makes cmdOne produce a **decimal**?

4. What line in the code makes cmdTen produce a **decimal**?

5. What line in the code makes cmdFive produce an **integer**?

6. What line in the code makes cmd100 produce an **integer**?

7. What line of code guarantees that the results will be truly random?

8. What is the keyword in Visual Basic that produces a random number between 0 and 1?

9. What type of numbers exist between 0 and 1?

10. When you multiply a number between 0 and 1 by 10, how many digits are to the left of the decimal point?


 * Study the code and the output from several tries before answer these questions.**

11. Describe the number that will be stored in memory in **LessTen** because of this line of code in **cmdTen**. **LessTen = 10 * Rnd **

12. Describe the number that will be stored in the variable, **UpTo5**, because of this line of code in **cmdFive**. **UpTo5 = 5 * Rnd **

13. What must **Rnd** be multiplied by to produce a number from 1 to 33?

14. Write the line of code that will put a random number from 1 to 33 in the variable, **UpTo33**.

15. True or False: To have a program user pick the highest number, use a textbox to get the number and multiply **Rnd** by the numerical variable where that number is stored.

16. Write the assignment statement for putting the random integer from 0 to the top number the user provided, into a variable in memory, if these declarations are given? Dim Top As Integer Dim UpToTop As Integer

Study the RandomNumber.frm **code** and its **output** first. Use your answers that you put on paper from the Do Now. Make sure to type your **name** in the name box on the left before you start the quiz. After you are finished, read the corrections and the explanations that go with them. Even if you got all the answers correct, please read the explanations that are provided below the problem. If you did not get 100%, take it again. Follow this link. media type="custom" key="7700317" **Correct your answers on your lined paper so you have that to refer to when you do your own program.!!** Program: **MyRandom.frm** Refer to the questions in the Do Now, your answers on paper, and the quiz explanations to help you with the program.

 Turn in your paper with your name, period and 16 corrected answers on it.

Tuesday November 30, 2010
//Objective: Write programs that use the random number generator.//

Get into Gaggle and save your recent programs to the desktop so that Miss Hangen can check them.

Finish back assignments __Scratch Program:__ **RandomFun.sb** Create a program in Scratch that uses the random number generator to do something randomly. Include an explanation in the **About this project** section when you save the program.

 Have Miss Hangen check your programs and upload them to your Gaggle digital locker.

Tuesday & Monday November 23 & 29, 2010
//Objective: Write programs that use the random number generator.//

Get into Gaggle and save your recent programs to the desktop so that Miss Hangen can check them.

__VB Program:__ **ThanksgivingGame.frm** __Scratch Program:__ **Thanksgiving.sb**

 Have Miss Hangen check your programs and upload them to your Gaggle digital locker. Turn in the directions sheets for both of today's programs.

Monday November 22, 2010
//Objective: Write a program that uses the random number generator to produces random numbers within a certain range.//

__Paper and Pencil:__ 1. Use a random number generator online @http://www.random.org/integers/ or @http://www.psychicscience.org/random.aspx to pick the number of the ticket that you are hypothetically being given from the range pictured to the right (410005 to 410514). Write down your ticket number. 2. Use a random number generator online to pick the 5 door prize winners' numbers picked from the tickets distributed which had a range of numbers from 410005 to 410514. Write down the ticket numbers. 3. Did you win a door prize? 4. Ticket numbers 410005 through 410514 were distributed. How many tickets were distributed? 5. Write the chance of winning a door prize as a fraction. 6. Write the chance of winning as a percentage.

Program: **RandomNumber.frm** Directions can be found in your binder.

 __Paper and Pencil/Fill-in-the-Blank:__ 7. In Visual Basic, a random decimal number between 0 and 1 is generated with the use of the keyword, Rnd **.**

//Objective: Discover why a program to calculate slope needs an If Then Else structure.// //Objective (Eligible Content M11C3): Relate slope to parallelism.//
 * Friday November 19, 2010**



Draw an x y coordinate system on a piece of graph paper. Plot these pairs of points and draw a line through each pair. (3, 6) (-2, 6) (5, -3) (2, 8) (10, -5) (10, 3) (-5, -9) (5, 9) Calculate the slope of each line and write it next to the line. Write the word horizontal by the horizontal line. Write the word vertical by the vertical line. Draw a line that is parallel to one of the lines and use two points on the line to determine its slope. What can you conclude about parallel lines and slope?

Study the SlopeLine.frm directions and explanation in your notebook. Discuss with the student next to you as necessary.

media type="custom" key="7585971"

Make sure to type your **name** in the name box on the left before you start the quiz. After you are finished, read the corrections on the quiz and reread the explanations in the notebook to clear up any misunderstandings. If you did not get 100%, click on **Try Again** at the bottom.

 Make sure your SlopeLine.frm program is correct and uploaded to your digital locker. Have Miss Hangen check it.

//Objective: Discover why a program to calculate slope needs an If Then Else structure.//
 * Thursday November 18, 2010**

__Paper and Pencil:__ 1. When typing a fraction into VB, what must surround the numerator of a fraction that has more than one thing in it? 2. When typing a fraction into VB, what must surround the denominator of a fraction that has more than one thing in it? 3. The slope of a line can be calculated by using the coordinates of two points on the line. The slope is the difference in the y direction divided by the difference in the x direction. Write the assignment statement for the formula for slope of the line that contains the points, (xone, yone) and (xtwo, ytwo).

Save this file to your desktop. Read ALL of the directions on pages 1-13 in your black binder for SlopeLine.frm __Program:__ **SlopeLine.frm** Test the **SlopeLine.frm** program with ALL the test data on page 13. Use your quality check off sheet to self-evaluate your program. Upload to your Gaggle digital locker, delete from the desktop and empty the recycle bin.

 __Paper and Pencil:__ 1. Do mathematical formulas work for all data? 2. Explain your answer.

//Objective: Apply the If Then Else structure to 3 different example uses.//
 * Wednesday November 17, 2010**

__Paper and Pencil:__ Answer these questions about the divide programs in VB. 1. When the code had no **If Then** structure, what happened when the denominator was zero? 2. When the code had an **If Then** structure, what happened when the denominator was zero? 3. When the code had an **If Then Else** structure, what happened when the denominator was zero? 4. Write one line of code to display a message box that looks like this.

__Read:__ **If Then Notes** __Program:__ **IfThenNotes.frm** Make a form and use the code on the notes pages to complete the program. Save to the desktop.

 Test the **IfThenNotes.frm** program with the test data on the notes pages. Upload to your Gaggle digital locker, delete from the desktop and empty the recycle bin. Study the notes for meaning. __Paper and Pencil:__ Summarize what you learned today in a few sentences.

//Objective: Use an If structure to prevent a program from crashing due to bad data.//
 * Tuesday November 16, 2010**

Scratch Program: **Divide.sb** Program: **Divide.frm** Make both programs better by following Miss Hangen's instructions.

Upload to your Gaggle digital locker.


 * Friday & Monday November 12 & 15, 2010**

//Objective: Assess ability to create assignment statements when provided the alebraic formula and declarations.// Go over Assignment Statement Syntax: Part III Study for the Assignment Statement Quiz. Finish **QuadraticFormula.frm**
 * Assignment Statement Quiz**

//Objective: Declare variables and constants.// //Objective: Write and debug programs using square root.// __Paper and Pencil:__
 * Thursday November 11, 2010**

1. Choose the correct declaration statements that would be necessary when the code contains this assignment statement: **PeriodT = 2 * PI * Sqr(Length/32)**



2. Write the correct declaration statements that would be necessary when the code contains this assignment statement: Program: **QuadraticFormula.frm** Self-evaluate with your Quality Check Off Sheet in your notebook. Have Miss Hangen check it. Study for the Assignment Statement Quiz we will be having tomorrow. Try some other numbers when you run QuadraticFormula.frm. 1. What are 2 sets of data that cause the program to crash? 2. Why does it crash with that data? We will look at a way to fix that in the near future. Upload to your Gaggle digital locker.
 * HypC = Sqr(LegA ^ 2 + LegB ^ 2) **

//Objective: Write assignment statements with absolute value and square root correctly.// //Objective: Write and debug programs using square root.// 1. Define absolute value. 2. Define magnitude. 3. Is there a radical (square root symbol) on the keyboard? 4. Write the function used for taking the square root in Visual Basic. 5. Write the function used for taking the absolute value in Visual Basic.
 * Wednesday November 10, 2010**
 * Paper and Pencil:**

Program: **QuadraticFormula.frm** Self-evaluate with your Quality Check Off Sheet in your notebook. Have Miss Hangen check it. Upload to your Gaggle digital locker.

//Objective: Write assignment statements with absolute value and square root correctly.// //Objective: Write and debug programs using square root.//
 * Tuesday & Wednesday November 9,10, 2010**

Simplify the following in your head: 1. |-3| //<span style="color: #000080; font-family: 'Times New Roman',Times,serif;">(Read as the absolute value of negative 3.) // 2. |17| 3. //<span style="color: #000080; font-family: 'Times New Roman',Times,serif;">(Read as the square root of 81.) // 4. Estimate the value of by using perfect squares surrounding 6 and their square roots.

Find out what the computer TI83 notation is for absolute value and square root by checking your answers. To find absolute value, choose Math --> to NUM. Compare your answers with another student, and make sure you both have everything correct before handing it in. Program: **QuadFormula.frm** Self-evaluate with your Quality Check Off Sheet in your notebook. Have Miss Hangen check it. Upload to your Gaggle digital locker.
 * Paper and Pencil:** Assignment Statement Syntax: Part III [[image:http://www.wikispaces.com/i/mime/32/application/msword.png width="32" height="32" link="http://hangenvb.wikispaces.com/file/view/AssignVBSyntaxIII.doc"]] [|AssignVBSyntaxIII.doc]