Assignment 4
Due June 9 at the start of class
Create a program that performs two different calculations.
-
Translate Temperature
-
Your form should have a label and a text box for entering the temperature.
-
Your form should have a label for displaying all the output and error messages
for the temperature.
-
Your form should include two option buttons (radio buttons): one for changing
Celsius to Fahrenheit and the other for changing Fahrenheit to Celsius. Place
these buttons within a frame so that they form a group. Neither button should
be selected when the form opens.
-
Your form should include a button to calulate the new temperature.
-
If neither option button is selected, then print an appropriate message in
the output label for the temperature.
-
If the temperature is not numeric or is not in the range -273 to 300, then
display an error message in the output label for the temperature.
-
If either of the option buttons is selected then perform the appropriate
calculation and place the result in the output label for the temperature.
Be sure to echo the input when you display the result. All numbers in the
output should be displayed with two decimal places.
-
C=5/9(F-32)
-
Calculate measurements for a circle
-
Your form should include a label and a text box for entering the radius of
a circle.
-
Your form should have a label for displaying all the output and error messages
for the circle.
-
Your form should include three check boxes: one for circumference, one for
area, and one for diameter. Place these buttons within a frame so that they
form a group.
-
Your form should include a button to calculate the checked measurements.
-
If the radius is not numeric or is not greater than 0, then display an
appropriate error message in the output label for the circle.
-
If none of them are checked, then display an appropriate error message in
the output label for the circle.
-
For each one that is checked, calculate the appropriate measurement and display
them in the output label for the circle. Be sure to echo the input when you
diplay the result. All numbers in the output should be displayed with two
decimal places.
Subroutine and Function Requirements: The purpose of this assignment is to
use lots of subroutines and functions.
-
You must declare and use functions or subroutines as follows.
-
Calculate the area of a circle for a given radius
-
Calculate the circumference of a circle for a given radius
-
Calculate the diameter of a circle for a given radius
-
Calculate the equivalent Celsius from a given temperature in Fahrenheit
-
Calculate the equivalent Fahrenheit from a given temperature in Celsius
-
Write a routine that will display a given error message in a given label.
The label will be one of the output labels for displaying either the temperature
or circle calculations. You are to change the appearance of this label as
follows. In all cases, you should choose values that are different from how
the label was declared in the form editor.
-
Change the font
-
Change the font size
-
Change the alignment
-
Change the border style
-
Change the background color
-
Change the foreground color
-
Write a routine that will reset a given label to its original values that
were declared in the form editor. The label will be one of the output labels
for displaying either the temperature or circle calculations. This routine
will be called from several other routines, such as
-
When either text box changes
-
When any of the radio buttons or check boxes is clicked
-
The following routines are for the circle calculations. Remember to echo
the radius somewhere in the output
-
Write a routine that will display the output for the area in the output label
for the circle calculations. It could also echo the radius.
-
Write a routine that will display the output for the circumference in the
output label for the circle calculations. It could also echo the radius.
-
Write a routine that will display the output for the diameter in the output
label for the circle calculations. It could also echo the radius.
-
The following routines are for the temperature calculations. Remember to
echo the original temperature somewhere in the output
-
Write a routine that will display the output for the Celsius in the output
label for the temperature calculations. It could also echo the original
temperature.
-
Write a routine that will display the output for the Fahrenheit in the output
label for the temperature calculations. It could also echo the original
temperature.
-
EXTRA CREDIT: It is possible to write one output routine for the circle and
one output routine for the temperature. Each of these would have extra
parameters. There would be no IF statements in these routines. If you look
closely at the circle output routines you should see how similar they are.
The same is true for the temperature output routines.
-
Write a routine that will validate that the temperature is numeric and that
it is in the range from -273 to 300. This should return a boolean value.
-
Write a routine that will validate that the radius is numeric and that it
is greater than 0. This should return a boolean value.
-
Each subroutine or function must be less than 26 lines of text. You will
lose 1 point off the assignment for each function or subroutine that is not
less than 26 line.
-
Most of these functions and subroutines are very short. Do not be concerned
if they only contain one line of code.
-
You may add other functions and subroutines if you need them.
Other Requirements
-
Use a global constant for Pi with the value 3.14159
-
All variables must be declared within subroutines or functions. You will
lose 1 point off the assignment for every reference to a global variable.
-
Choose a background color for the form.
-
Choose a different background color for everything else except the text boxes.
Leave the text boxes as white. Change the style of the buttons to graphical
to make them transparent.
-
Choose a 12 point font.
-
Draw a rectangle or frame around each of the calculation areas. (You may
use a group in VB.NET)
-
Include an Exit button
-
To hand in the assignment
-
Zip the entire project and upload it via the web.
-
Hand in a printout of your .frm file for your form. Do not print this
from within VB. Open the file in Notepad and print it from there. (If you
are using .NET, print out the .vb file)
-
Here is an executable of my project : hw4.exe