Exercises
|
Exercise 1: Stars (Console Application) |
Exercise 2: Guess Number (Windows Application) |
Exercise 3: Lucky 7 (Windows Application) |
This exercise is a Console Application
Part a
Prompt the user to enter the number of rows and columns
Draw a rectangle similar to the following if, for example, the user enters 4 rows and 5 columns
* * * * *
* * * * *
* * * * *
* * * * *
Part b
Prompt the user to enter the number of rows
Draw a triangle similar to the following if, for example, the user enters 5 for the number of rows
* * * * *
* * * *
* * *
* *
*
Part c
Prompt the user to enter the number of rows
Draw a shape similar to the following if, for example, the user enters 5 rows
*
* *
* * *
* *
*
Use a windows application
Place an appropriate title on the page
Ask the user to guess an integer between 1 and 5
In the code section assign the mystery number. If the user picks it, in another text box, labeled RESULTS, give an appropriate response depending upon whether the number was correctly guessed.
This exercise is a Windows Application
Create a form similar to the following.
Note that it uses 5 Labels, 5 Text Boxes, 3Picture Boxes, and 1 Button
(Note that only 1 Picture Box is shown below, you need 3)
For each Picture Box.
Single click on the box, from the properties on the right, select Image, Import, and select a picture that you have saved on z drive.
Select SizeMode. Select StretchImage

Write code that runs from the Start button.
The code will, for each run, calculate 3 random numbers in the range 1 to 7 (including 1 and 7).
The numbers will be placed in Windows 1 through 3 (Text Boxes).
An appropriate picture will appear in 1 of 4 Picture Box depending on whether no sevens, 1 seven, 2 sevens or 3 sevens are rolled. Note that only 1 Picture Box is shown above.
The code will keep track of the number of times the program has been run and the total number of sevens rolled.
These results will be printed the the text boxes shown by Number Rolls and Number Sevens.
Prompt the user to pick an level of difficulty for playing.
If Beginning level is picked, then the random numbers will be in the range 1 to 7 as above.
If Lucky level is picked, then the random numbers will be in the range 1 to 10 as above.
OPTIONAL
Add a Help form and a button on the Start form to go to the Help form.
Add a brief description of the program on the Help form and add a button to return to the Start form.
Public
Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim randomizer As New Random
TextBox1.Text = randomizer.Next(1, 8)
TextBox2.Text = randomizer.Next(1, 8)
TextBox3.Text = randomizer.Next(1, 8)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage 'Allows picure to fit
PictureBox1.Visible = False 'Makes picture invisible
'Note: Place next 3 lines on same line - note use of parentheses around booleans
If (((TextBox1.Text = 7) And (TextBox2.Text <> 7) And (TextBox3.Text <> 7)) Or ((TextBox1.Text <> 7) And
(TextBox2.Text = 7) And (TextBox3.Text <> 7)) Or ((TextBox1.Text <> 7) And (TextBox2.Text <> 7) And
(TextBox3.Text = 7))) Then
PictureBox1.Visible = True 'Makes picture visible
End If End SubEnd
Class