Question
SDEV 140 / Introduction to Software Development S12 Software Development Lab 3 / INTRODUCTION: In this assignment, you will develop the logic for, and then
SDEV 140 / Introduction to Software Development S12 Software Development Lab 3 / INTRODUCTION: In this assignment, you will develop the logic for, and then create, the Order Input form for the DroneDogs project. There are two parts to the assignment. In Part 1, you will complete the Algorithm Development Exercise, which will help you determine what programming steps you will need to create in Visual Basic. In Part 2, you will use the FORM from lab 2.5 to add VB code, test it, and paste a screen shot showing that it runs correctly. PRELIMINARY: Read the section Understanding Constants, from Chapter 5 in the Visual Basic textbook on Books 24x7. Create and/or run the Constants Demo program. (If you downloaded the source code files from the publishers website, you can open the project in Visual Basic using File / Open Project-Solution, then browse to the folder where the project is stored, and select the Constants Demo.sln file. You are encouraged to experiment with the code to understand how it works. ASSIGNMENT PART 1: Complete the Algorithm Development Exercise below. Enter statements where instructed in red. ALGORITHM DEVELOPMENT EXERCISE: To process the order, you will need constants and variables. Both have data types, and for numeric values, the preferred data types are Integer for whole numbers, and Double for values with decimal amounts. The Hungarian Notation prefix for Integer types is int, and the prefix for Double types is dbl. Lets start with constants (described in the textbook). There are two values that will not change during the program: the cost per hot dog, and the sales tax rate. Both of them may contain decimal amounts, so they should be declared as Double type constants. In Visual Basic, a constant is notated by the keyword Const. Constant names are usually written in upper case, with underscores to separate words. You also have to assign the value to a constant at the time you declare it (because, by definition, the value of a constant cannot be changed). For example, a constant Double representing an interest rate of 3.5% could look like this: Const DBL_INTEREST_RATE as Double = 0.035 Now, write statements declaring and initializing constants for: A sales tax rate of 7%: [type your answer here] The price of a DroneDogs hot dog at $1.99: [type your answer here] Next, you will have to get the number of each kind of hot dog from the three text boxes. You might also want a variable for the total number of dogs ordered (because they are all the same price). What kind of data type should these variables be? They should be Integer variables, because people will order a whole number of hot dogs, not half a dog, etc. You dont have to set an initial value for these variables. Variables are notated by the keyword Dim. For example, if DroneDogs were selling tacos, a variable for the number of tacos could look like this: Dim intNumTacos as Integer Now, write statements declaring integer variables for: The number of beef dogs ordered: [type your answer here] The number of pork dogs ordered: [type your answer here] The number of turkey dogs ordered: [type your answer here] The total number of hot dogs ordered: [type your answer here] Next, you need variables for the subtotal, sales tax amount, and total cost. These should be Double types, because they will contain decimal amounts. These are called floating-point variables. For example, if there were a delivery charge based on the subtotal, a variable for that charge could look like this: Dim dblDeliveryCharge as Double Now, write statements declaring floating-point variables for: The subtotal for the order: [type your answer here] The amount of sales tax: [type your answer here] The total cost of the order: [type your answer here] Finally, you need to do the arithmetic to add the order numbers, compute the sales tax amount, and compute the final total. Remember that the receiving variable is alone on the left-hand side of the equals sign, and the computation is on the right-hand side. You have already declared your variables. Now, write statements that will compute the correct values for: The total number of hot dogs ordered: [type your answer here] The subtotal (before taxes): [type your answer here] The amount of sales tax: [type your answer here] The total cost of the order: [type your answer here] ASSIGNMENT PART 2: Use the DroneDogs Project Guidelines below, and your textbook, to compile and run a Visual Basic project called DroneDogs, which includes an order input form that calculates the subtotal, sales tax, and total cost for hot dogs from DroneDogs. Test the program to make sure it produces correct output, and paste a screen shot where instructed. DRONEDOGS PROJECT GUIDELINES: To code the Calculate Order button, double-click it, and the code header will appear in the code window. Declare the variables and constants, by adding the code from the Algorithm Development Exercise Steps #1-4 above. IMPORTANT: Above each section, write a COMMENT about what is happening in the code. Comments start with an apostrophe, such as 'Declare variables and constants Youll need to extract text from the text boxes and convert them to the numeric variables you declared. To convert the entries in the text boxes into numerical amounts that can be used in calculations, there is a function called Convert.ToInt32. For example, if you want to convert the number of beef dogs from the beef dogs text box into its corresponding integer variable, depending on what you named that text box and variable, the statement might be: intNumBeef = Convert.ToInt32(txtBeefDogs.Text) After you have calculated the amounts, youll need to convert those numerical amounts back to text, so that you can display them in the text boxes, using a function called ToString. To make your money amounts display with a dollar sign and 2 decimal places, there is an argument ("c2") meaning currency format, 2 decimals. For example, to display the subtotal amount in the subtotal text box, depending on what you named them, the statement might be: txtSubtotal.Text = dblSubtotal.ToString("c2") To code the Submit button, double-click it, and the code header will appear in the code window. Enter a comment that you are displaying a message box thanking the user. Then, the only code line you need for the Submit button is the line: MessageBox.Show("Thank you for ordering from DroneDogs!") To code the Exit button, double-click it, and the code header will appear in the code window. Enter a comment that you are exiting the program. Then, the only code line you need for the Exit button is the line: Me.Close() After you enter your code, select Save All, then use the Build menu to Rebuild DroneDogs. If you have error messages, look closely at the lines that are mentioned and read the error message. Check your spelling, spacing and punctuation and determine where the error is. There is a document in Session 12, VBProject1_SampleCode.docx, which shows some sample working program code. Use this to help debug your own program, but do not copy it directly into your code, because the names for the components, constants and variables may be different than what you are using from the S11 SDEV Lab 1 Order Form. Also, you must include comments in your code, which are not present in the sample code. This is just a guide. When the program compiles successfully, click Debug, and Start Without Debugging to run the program. You should be able to enter the number of each of the three types of hot dogs. NOTE: Enter 0 for any type of hot dog you are not ordering (do not leave it blank). Click Calculate Order, and the program will correctly compute the subtotal, the amount of sales tax, and the total cost of the order. If there are errors, read the error messages carefully, look at how you spelled your variable names, and check punctuation. Correct your errors, save, build and run your program again until you get it working correctly. There is a sample screen shot below. You will submit your own screen shot when your program runs correctly. Run the program, entering numbers for 1 beef dog, 2 pork dogs, and 3 turkey dogs, and click Calculate Order. Check your arithmetic on a calculator to make sure your subtotal, tax amount and meal total are correct. Take a screen shot of this form by clicking on the title bar to be sure it is selected, then holding down the ALT key and pressing the PrntScrn key. (If you dont have a PrntScrn key, use the Windows Snipping Tool to get a screen shot.) PASTE the screen shot where indicated below by selecting Edit / Paste from the menu, or pressing CTRL-V. Select Save All again, rebuild the program, and run the program again by clicking Debug, and Start Without Debugging. Now you should be able to enter an order, and see the calculated amounts. Exit Visual Studio. Jane Doe Beef Dogs 1 Pork Dogs: 2 TurkeyDogs 3 Calculate Order Submit Order Subtotal $11.94 Sales Tax $0.84 Total Cost $12.78 Exit I need only the visual basic code, only the code. Thanks for your help.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started