ASSIGNMENT:
1) Exercise 9, steps b and c, on page 298-299 of the lab textbook, “Clearly Visual Basic”, at the end of Chapter 16. You will use the experience you have gained so far in this class to create an application. Create the application as instructed, and make the following changes:
a. Enlarge your form if necessary. In the bottom center area of the form, add a label with the Text property, Designed by, followed by your name.
b. Add a button between the Calculate and Exit buttons, with the text “Clear”, and code it to clear the two input text boxes and the output labels.
c. Put five comment lines at the top of the code page, listing:
‘Project Name: Water Bill Project
‘Class: CINS 113-nn [section number]
‘Programmer: [your name]
‘Date: [date last modified]
‘Purpose: [1- or 2-line description of program]
d. Put brief comments in all sub procedures, explaining what that section does: the button click procedure, the sub procedure for making the calculations, the sub procedure for displaying the results, as well as the Clear button and the Exit button sub procedures.
e. Declare the rate of .00205 dollars per gallon as a constant.
f. The variables for Current reading, Previous reading and Gallons used should be integers.
g. Your message box for invalid input should include these things:
i. The message should include the numbers the user entered, for example: “ERROR: Current reading (2000) cannot be less than Previous reading (3000).”
ii. The title bar text should say “Invalid Input”.
iii. The message box button should say “OK”.
iv. The message box icon should be the Error icon.
h. The output for the total charge should be displayed in currency format.
i. Run the program, entering 8450 as the Current reading, and 6225 as the Previous reading. Click Calculate, then take a screen shot of the form, paste it at the end of this document, and press ENTER twice.
j. Clear the text boxes, and run the program again, entering 8450 as the Current reading, and 8995 as the Previous reading. Before you click Calculate, take a screen shot of the form, paste it at the end of the document and press ENTER twice.
k. Then click Calculate. A message box should pop up with an invalid input error message. Take a screen shot of the message box and paste it at the end of this document.
l. Go to Code View for your form, copy all the code (using Edit / Select All and Edit / Copy, or CTRL-A and CTRL-C), and paste it at the end of this document (using Edit / Paste or CTRL-V).
m. You do not have to do step 9a, listing output, input and processing items and a pseudocode algorithm.
2) At the top of this page, replace the line after “Student’s name” with your name.
3) Click the Office Button, Prepare, and Properties, and type your name as the Author, and CINS 113 as the Subject. Close the Document Properties area by clicking the X at the right end of the yellow bar.
4) Save this Word document. Close the document.
5) In Blackboard, go to Session #8 in Class Sessions when it is made available, and click on the View/Complete Assignment link.
6) Attach this file (CINS 113 VB Midterm Project.doc) and click Submit.
HINTS:
1) To restrict a text box to accepting only certain characters, see page 190, Coding the KeyPress event procedure
2) To exit, see Chapter 4
3) Suggestion: pass the gallons used and total charge variables to the sub procedures by reference
NOTES:
1) Any time you make changes to your Visual Basic program, you should use File / Save All to save all files associated with your program.
2) In Blackboard, you can check to see if your file was submitted correctly. Go to My Grades, and in the column for this Lab, there should be a white exclamation mark on a green background. Click on the exclamation mark, and open up the submission page. Right-click on the link for your file, and see if it opens correctly. If not, contact your instructor immediately and ask for your attempt to be cleared.
CHECKLIST FOR SUBMITTING THE ASSIGNMENT:
· You have entered your name at the top of this document after “Student’s name”
· In the Properties area, you have entered your name as the Author, and CINS 113 as the Subject
· You have attached this file, CINS 113 VB Midterm Project.doc, using the Blackboard View/Complete Assignment link
· You are ready to click Submit
· Check your file submission using the instructions in the Note section above
In this excise, you code an application that calculates a water bill.
The clerk at the water department will enter the current meter reading and the previous meter reading in two text boxes.
The application shuold calculate and display the number of gallons of water used and the total charge for the water.
The charge for water is 2.05 per 1000 gallons, or .00205 per gallon.
Use two independent Sub procedures: one to make the calculations and the other to display the results.
Call both Sub procedures from the Calculate button's Click event procedure.
Make the calculations only when the current meter reading is greater than or equal to the previous meter reading;
otherwise, display an appropriate message in a message box.
Step B:
Create a visbual basic windows application. Use the following names for the solution and project, respectively:
Water Bill Solution and Water Bill Project. Save the application in the ClearlyVB2010/Chap16 folder.
Change the name of the form file on your disk to frmmain.vb. If necessary, change the form's name to frmMain.
Step C: Create the interface shown in Figure 16-24 and then code the application. Be sure to code each text box's KeyPress and TextChanged Event procedures.
Save the solution and then start and test the application. Close the Code Editor window and then close the solution.