The instruction is in the following document. After finishing, please send me the code and a screenshot of resulting image.
Here are some guidelines for your program:
1.
Follow the correct steps to sign onto the computer using the correct ID. Next, follow the
instructions to start Visual Basic. If you aren’t sure how to do this, ask the instructor. Do
not simply ask the lab assistants. They are not tutors and will not be able to help you
complete your project.
2.
Select “File > New Project” to start a new project.
3.
Select “Windows Forms Application” and click the OK button.
4.
Make a form that contains labels, text boxes, and 2 buttons.
a. Make labels for the radius, diameter, circumference, surface area, and volume text.
b. Make a text box for the radius (i.e., the input).
c. Make labels for the diameter, circumference, surface area, and volume values (i.e.,
the output).
d. Make one button labelled “Calculate” and another labelled “End”.
5.
Write the source code for the “Calculate” button:
a. Use the Dim statement to define the variables for this program, including:
Description Variable name
Radius
rad
Diameter dia
Circumference circ
Surface area surf
Volume
vol
Type
Double
Double
Double
Double
Double
Example code (for the first variable name):
Dim rad As Double
b. Assign the rad variable to the data value contained in the radius text box.
rad – Val (radius.Text)
c. Write the code to calculate the diameter, circumference, surface area, and volume of
the sphere. You will need to look up the appropriate formulas using a math book or a
trusted online source. Note: Some of the formulas use n. In Visual Basic, this may be
obtained using the Math.PI constant.
d. Assign the 4 labels (that you created in step 4c) to their respective variables. The
following lines of code assume that you named these labels diameter,
circumference, surfacearea, and volume. If you chose different names,
adjust the following lines of code accordingly.
diameter.Text = Str (dia)
circumference. Text = Str (circ)
surfacearea.Text = Str(surf)
volume. Text – Str (vol)
Write the source code for the “End” button.
Add comments to the source code. First, add a comment that identifies you as the
programmer. For example:
This program was written by (your name)
Add other comments throughout the code to explain the various formulas and features of
your program. This is very important.
Test your program. Start by using a radius of 1, since it will be easy to verify the results
without using a calculator. Next, use other small values (5, 10, etc.) and verify that the
results are correct.
6.
7.
8.
9.
Once you are sure that your formulas are correct, do the following:
a. Print the source code in PDF format.
b. Make “screen shots” using the SNIP tool and paste the resulting image into a Word
document, and then save it as a PDF file. Capture screen shots with the results for the
following radius values:
A men’s regulation basketball, in inches (you will need to research this)
The Earth, in miles (Assume that the Earth is a perfect sphere, and that you
are using the radius at the equator. Again, you will need to research this
amount and cite your source of information.)