Computer Science Visual Basics app.
1
Lab 3 CS 105 Fall 2014
Problem description:
An online greengrocer, who sells organic fruit, offers free shipping when the amount charged for just the fruit is at least $50. If the amount charged for just the fruit is less than $25, he charges a handling
surcharge of $5.00. The following items are for sale through his Internet store (all prices are per pound):
Apples: $3.25
Grapes: $2.75
Oranges: $3.50
Peaches: $3.75
Pears: $4.30
When charged, shipping is a flat rate of $7.50. Sales tax is 7.9% on the
total charged for just the fruit, not including surcharge or shipping.
Design an app to collect the necessary information from the user, and
then calculate and display the following:
1. The total amount charged for the fruit 2. The amount of tax charged 3. The amount of shipping charged 4. The amount of surcharge 5. The total amount charged for the order
NOTE: You must use either a single If…Then…ElseIf construct
(example code page 109) OR a single Select…Case Multiple-Selection Statement (pages 159 – 163) for the decision making component of this
program.
Due dates:
11 am Section: Tuesday October 21, by the end of lab.
2 pm Section: Wednesday October 22, by the end of lab.
2
Objectives:
1. Demonstrate the ability to outline the steps needed to complete the project before beginning to program.
2. Demonstrate the ability to correctly code the logic of a selection statement construct.
3. Demonstrate the ability to use the Decimal data type.
4. Demonstrate the ability to use constants. 5. Demonstrate the ability to properly format display of currency values.
Methods:
1. This is your second graded project. It is worth 10% of your total grade. 2. Study and understand the problem that needs to be solved in this project. The
problem description is at the top of this document.
3. Outline the steps that you need to follow in order to solve the problem. This outline must be turned in with your completed project. Include in this outline the
variables and constants that you will need to declare, any calculations that will need to be performed, and, most importantly, the decision logic that needs to be implemented.
4. Draw a diagram of the form that you will need to create to solve the problem. This diagram must be turned in with your completed project. You might consider
adding a label somewhere near the top of the form providing instructions to the user. E.g.: “Greengrocer Order Form: Enter # Pounds Of Each Item To Purchase”
5. In your CS account, create a new folder and name it Lab3. Your completed
project must be saved in this folder. If the grader cannot find your work, it will not be graded and you will get a zero.
6. Create a new project and name it Greengrocer. Remember to save it in the Lab3 folder.
7. Change the file name to Greengrocer.vb
8. Change the name of the form to GreengrocerForm 9. Change the text property of the form to Organic Greengrocer
10. Complete the form according to the diagram that you drew in Step 4, following the following naming conventions, that you used in Lab2, for the Name property of the objects on the form. Recall that these are the same naming conventions for
variables, and that all names must be unique. 11. The naming convention for constants is ALL UPPER CASE, separating words
with an underscore. 12. After completing the form, double click the Button that you included on the form.
This will generate the outline of the code that you will need for the click event of
the button, and it will take you to the source code of your project. 13. You are now ready to begin programming.
a. Within the button event handler, first add, as comments, each of the steps that you decided on in Step 4 above.
b. To each of these steps, now add the code needed to implement this
functionality.
3
c. REMINDER: The naming convention for constants is ALL UPPER CASE, separating words with an underscore.
d. FORMAT monetary output to display as currency by using String.Format as follows:
totalLbl.Text = String.Format(“{0:C}”, total)
14. What to turn in: a. The programming steps needed to solve the problem (digital or hard copy) b. The drawing of your form (digital or hard copy)
c. The source code, with the pledge signed. If working as a pair, it must be signed by both students.
15. Grading rubric: a. Pseudocode:
i. Listing of the programming steps needed to solve the problem
(digital or hard copy). (5 points) ii. Drawing of the form submitted (digital or hard copy) (5 points)
b. Source code i. The header contains all required information, including the names
of both students, CS account where project located, and signed
pledge. (5 points) ii. Proper naming convention for variables and the name properties of
the objects on the form. (i.e. begin with lower case letter, no spaces, each subsequent word begins with upper case letter). (5 points)
iii. Comments included to describe the purpose of each block of code. (5 points)
iv. Variable declarations of the Decimal data type properly performed. (5 points)
v. Monetary results formatted as currency. (5 points)
vi. The correct calculations implemented to solve the problem. (5 points)
vii. Constants are used appropriately, with proper naming convention (all upper case, with words separated by an underscore). (5 points)
viii. The program correctly uses a single If…Then…ElseIf construct
OR a single Select…Case multiple-selection statement construct for the decision logic. (20 points) NOTE: If multiple constructs
are implemented, you will receive zero points for this component. c. Program execution.
i. The program compiles and runs with no problems. (10 points)
ii. The program gives the correct result when run with test cases. (25 points)
4
16. Sample Output, for four different test cases: