Question

If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own.

INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, 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 work with a partially complete Drone Dogs project in Visual Basic to implement additional functionality, test it, and submit your completed version of the project as a zipped folder.

PRELIMINARY: You should have read the first five chapters from the Books 24x7 Visual Basic textbook prior to attempting this assignment. Be prepared to refer back to that text, to search for tutorial information online as needed (there is a LOT of it), and to ask your instructor questions. You are encouraged to experiment with code samples and examples from the text and other sources to understand better how it works.

ASSIGNMENT PART 1:

Complete the Algorithm Development Exercise below. Enter statements where instructed in red. You’ll submit this document with your edits as part of the assignment submittal.

ALGORITHM DEVELOPMENT EXERCISE:

To process the customer order, you will need to define constants and variables. This is different than in Python, in that you have to declare data types for both, and you have to declare your variables before using them. For numeric constants or variables, please use the data types 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.

Let’s start with constants. There are two values that will not change during the program: the cost per hot dog, and the sales tax rate. Since they do not change, you can declare them as constants in your program so that the compiler will let you know if you inadvertently try to change them programmatically.

Both the hot dog price and sales tax rate may contain decimal amounts, so they should be declared as type Double constants. In Visual Basic, a constant is denoted by the keyword Const. By convention, constant names are usually written in all 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, the declaration of a constant Double representing an delivery charge rate of 3.5% could look like this in Visual Basic:

Const DBL_DELIVERY_CHARGE_RATE as Double = 0.035

YOU: Write statements to declare 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, the user will enter the number of each kind of hot dog desired into one of three text boxes on the input form. You’ll need variables for each of these; you might also choose to declare a variable for the total number of dogs ordered (because they are all the same price).

Because people must order a whole number of hot dogs, not fractions of a hot dog, you should declare these as Integer variables. (You don’t have to set an initial value for these variables, though it is common practice to initialize all variables – to zero, if no other value is more appropriate.)

Variables in Visual Basic are declared using the keyword Dim.

For example, if DroneDogs were selling tacos, an appropriately named Integer variable for the number of tacos could look like this:

Dim intNumTacos as Integer

YOU: 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 are values that your program will calculate, based upon the constants and variables declared above. These should all be Double types, because they will contain decimal amounts. Generally, within programs, decimal variables are called floating-point types – Double is an example of a floating-point type.

For example, if there were a delivery charge based on the subtotal, an appropriately named variable for that charge could look like this:

Dim dblDeliveryCharge as Double

YOU: 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 determine the total number of hot dogs orderd, find the subtotal for that many hot dogs based upon that constant price, compute the sales tax, and compute the final total. Just as in Python, Visual Basic calculations and assignments require 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.

For example, if you were determining the gross pay for an employee based upon hours worked and hourly rate, an assignment statement could look like this (if the variables dblGrossPay, dblHoursWorked, and dblPayRate were previously declared and had values).

dblGrossPay = dblHoursWorks * dblPayRate

YOU: 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:

Follow the steps below to finish the DroneDogs project using a starter project provided to you. You’ll open that attached project file for the Drone Dogs project and complete the steps requested. After you’re finished, you’ll have a functioning DroneDogs application, which includes an order input form that calculates the subtotal, sales tax, and total cost for hot dogs from DroneDogs.

Be sure to aside enough time to do this. You may have to search for additional help in the Books 24x7 text, or find other sources online or via your instructor.

DRONEDOGS PROJECT GUIDELINES:

Download and unzip the project folder provided in this module to a location on your computer.

Start Visual Studio, and open the Visual Basic project file DroneDogs.sln inside the root level of the project folder. That project is a Windows Forms application named DroneDogs and has a mostly complete order form already built into it.

Use the Build menu, Rebuild Solution to rebuild the DroneDogs project - this will compile the program into executable form or will let you know of any syntax errors you have (there should be NONE at this point). Once you have rebuilt DroneDogs successfully, select the Debug Menu, Start Without Debugging to run the program. Your input form should appear but you won’t be able to do much with it. You’ll have to exit the ‘run’ by clicking the Close button (X) at the top right of the form.

Use the visual editing capabilities of the Visual Studio IDE to make the following changes to the form and controls on it (buttons, labels, etc.) itself. You’re editing the attributes (variable values) of the various controls – setting the default values of those attributes. Note that these can be changed again, programmatically, at run time.

If you cannot already see the DroneDogs form displayed, in the Solution Explorer Window, double click on DroneDogs.vb to open the visual editor for the form. You’ll see it tabbed in the main window of Visual Studio as DroneDogs.vb [Design]

Right-Click on the entire form and view it’s Properties. You should see a Properties window open on the right for DroneDogsOrder System.Windows.Forms.Form

Change the Text property of the form from No Name to your name (for example – Fred Garvin). You should see the name on the title bar of the form change immediately!

Check each of the labels, text boxes, buttons and picture box controls on the form to make sure that the Name property and Text property are appropriate. For example: The first label should be named lblBeefDogs, and it’s text property should be # Beef Dogs.

If either property is incorrect or poorly/inconsistently chosen, (e.g. a button named Button1 instead of something meaningful like btnCalculateSubTotal – or – a button used to calculate the subtotal, but which shows “Calculate Income Tax” on screen), then change the Name property and/or Text property as appropriate to what the Order Input form indicates.

For the last three text boxes, change the Read-Only property to True. This will ensure that the user is not able to click into those text boxes when the program runs in order to type values there - they are only used by you, programmatically, to display output information.

You’ve noticed by now that the Subtotal Text box has no label. Find the Toolbox (if you don’t see it, you can choose it from the View Menu). Double click on Label and you’ll see Label1 added to your form. Drag and resize that Label to the appropriate location, and change its Name and Text properties to appropriate values.

MAKE SURE YOU HAVE ALL ITEMS ABOVE COMPLETE BEFORE CONTINUING ON

So far you’ve used the visual editing properties of Visual Studio to edit the initial look of the application. Now you have to do some actual coding to handle things that happen/change during execution.

To code the Calculate Order button, double-click that button in the visual editor (on the form), and the code header will appear in the code window. You’ll see the following:

Declare the variables and constants, by adding the code from the Algorithm Development Exercise Steps #1-4 above into the appropriate locations.   You’ll see comments such as 'Declare constants or 'Declare variables above each location where you have code to add. (Normally, you’d be adding these comments yourselves).

You’ll need to extract the user typed text from the appropriate text boxes and convert those values into the Integer variables you declared. Enter those statement where the comments indicate.

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)

You’ll have to write the code to calculate the total number of hotdogs ordered, using the appropriate variable you’ve already declared to hold the total, and adding up those values you just extracted from the text boxes.

You’ll have to write the code to use those numerical values and the constants you’ve already declared, to calculate the Subtotal, Sales Tax, and Total Cost amounts. For instance, you might calculate a delivery charge as:

dblDeliveryCharge = DBL_DELIVERY_CHARGE_RATE * dblOrderSubtotal

After you have calculated the Subtotal, Sales Tax, and Total Cost amounts, you’ll 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:


txtOrderSubtotal.Text = dblOrderSubtotal.ToString("c2")

To code the Submit button, double-click it, and its 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 your meal from DroneDogs!")

To code the Exit button, double-click it, and its 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:

After you enter your code, select File Menu, Save All; and then use the Build menu, Rebuild Solution to rebuild DroneDogs. This will compile the program into executable form or will let you know of any syntax errors you have. If you have errors, 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.

When the program compiles (builds) successfully, select the Debug Menu, Start Without Debugging to run the program. Your input form should appear, and 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 should correctly compute the subtotal, the amount of sales tax, and the total cost of the order. If there are error messages, read them carefully, look at how you spelled your variable names, and check punctuation. Once it runs, use a calculator to verify that your program actually runs correctly – you may have logic errors that cause your program to calculate the wrong values, even if it ‘runs’. Correct all errors, save, build and run your program again until you get it working correctly.

There is a sample screen shot below.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

below is the solution:

code:

Public Class DroneDogsOrder
    Private Const BEEF As Double = 1.99 'beef dogs price is 5
    Private Const PORK As Double = 1.99 'pork dogs price is 6
    Private Const TURKEY As Double = 1.99 'turkey dogs price is 7
    Private Const DBL_DELIVERY_CHARGE_RATE As Double = 0.035 'delivery charge
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim BEEF_TOTAL As Double 'for calculate the beef hotdog
        Dim PORK_TOTAL As Double 'for calculate the pork hotdog
        Dim TURKEY_TOTAL As Double 'for calculate the turkey hotdog

        Dim dblOrderSubtotal As Double 'for calculate the subtotal of the all entered hotdogs
        Dim Tax As Double   'for calculate the tax in percentage of the all entered hotdogs ( depent on the tax how much they want)

        Dim dblDeliveryCharge As Double
        Dim dblGrossPay As Double 'calculate the total amount

        Dim intNumBeef As Integer
        Dim intNumPork As Integer
        Dim intNumTurkey As Integer
        intNumBeef = Convert.ToInt32(txtBeefDogs.Text)
        intNumPork = Convert.ToInt32(txtBeefDogs.Text)
        intNumTurkey = Convert.ToInt32(txtBeefDogs.Text)

        If intNumBeef.ToString = "" Then   'give the error if the beefdos is empty
            MsgBox("Please Enter no. of Beef Hotdogs ")
        ElseIf intNumPork.ToString = "" Then 'give the error if the porkdogs is empty
            MsgBox("Please Enter no. of Prok Hotdogs")
        ElseIf intNumTurkey.ToString = "" Then 'give the error if the turkeydogs is empty
            MsgBox("Please Enter no. of Turkey Hotdogs")
        ElseIf intNumBeef.Equals("0") Then ''give the error if the beefdos is 0
            intNumBeef = 0
        ElseIf intNumPork.Equals("0") Then 'give the error if the porkdogs is 0
            intNumPork = 0
        ElseIf intNumTurkey.Equals("0") Then 'give the error if the turkeydogs is 0
            intNumTurkey = 0
        Else
            If intNumBeef = 0 Then
                BEEF_TOTAL = 0
            Else
                BEEF_TOTAL = BEEF * intNumBeef
            End If

            If intNumPork = 0 Then
                PORK_TOTAL = 0
            Else
                PORK_TOTAL = PORK * intNumPork
            End If

            If intNumTurkey = 0 Then
                TURKEY_TOTAL = 0
            Else
                TURKEY_TOTAL = TURKEY * intNumTurkey
            End If


            dblOrderSubtotal = BEEF_TOTAL + PORK_TOTAL + TURKEY_TOTAL     'add all the beef pork turkey dogs
            txtSubtotal.Text = dblOrderSubtotal.ToString("c2") 'display to the subtotal textbox with three digit format number

            Tax = (dblOrderSubtotal * 7) / 100     'calculate the tax in percentage here calculated 7%, or depend upon the tax user want to calculate 1%....100%
            txtTax.Text = Tax.ToString("c2") 'display to the tax textbox with three digit format number

            dblDeliveryCharge = DBL_DELIVERY_CHARGE_RATE * dblOrderSubtotal

            dblGrossPay = dblOrderSubtotal + Tax + dblDeliveryCharge      'calculate the total cost of the all entered dogs with delivery charges
            txtOrderSubtotal.Text = dblGrossPay.ToString("c2") 'display to the Total cost textbox with three digit format number
            MessageBox.Show("Thank you for ordering your meal from DroneDogs!")
        End If
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close() 'close app
    End Sub

    'key press event to for beef enter only number and backspace
    Private Sub OnlyNumberBeef_KeyPres(sender As Object, e As KeyPressEventArgs) Handles txtBeefDogs.KeyPress 'keypress event for input only number for the beefdogs textbox
        If Char.IsNumber(e.KeyChar) Then   'Only number is accepted
            e.Handled = False
        ElseIf e.KeyChar = Convert.ToChar(Keys.Back) Then 'backspace allowed incase of wrong input
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    'key press event for pork to enter only number and backspace
    Private Sub OnlyNumberPork_KeyPres(sender As Object, e As KeyPressEventArgs) Handles txtPorkDogs.KeyPress 'keypress event for input only number for the porkdogs textbox
        If Char.IsNumber(e.KeyChar) Then   'Only number is accepted
            e.Handled = False
        ElseIf e.KeyChar = Convert.ToChar(Keys.Back) Then 'backspace allowed incase of wrong input
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    'key press event for turkey to enter only number and backspace
    Private Sub OnlyNumberTurkey_KeyPres(sender As Object, e As KeyPressEventArgs) Handles txtTurkeyDogs.KeyPress 'keypress event for input only number for the turkeydogs textbox
        If Char.IsNumber(e.KeyChar) Then   'Only number is accepted
            e.Handled = False
        ElseIf e.KeyChar = Convert.ToChar(Keys.Back) Then 'backspace allowed incase of wrong input
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub OnlyNumberSubtotal_KeyPres(sender As Object, e As KeyEventArgs) Handles txtSubtotal.KeyUp 'clear the textbox of all the input and the output except subtotal
        txtBeefDogs.Text = ""
        txtPorkDogs.Text = ""
        txtTurkeyDogs.Text = ""
        txtTax.Text = ""
        txtOrderSubtotal.Text = ""
    End Sub

    Private Sub OnlyNumberTax_KeyPres(sender As Object, e As KeyEventArgs) Handles txtTax.KeyUp 'clear the textbox of all the input and the output except tax
        txtBeefDogs.Text = ""
        txtPorkDogs.Text = ""
        txtTurkeyDogs.Text = ""
        txtSubtotal.Text = ""
        txtOrderSubtotal.Text = ""
    End Sub

    Private Sub OnlyNumberTotalCost_KeyPres(sender As Object, e As KeyPressEventArgs) Handles txtOrderSubtotal.KeyPress 'clear the textbox of all the input and the output except total cost
        txtBeefDogs.Text = ""
        txtPorkDogs.Text = ""
        txtTurkeyDogs.Text = ""
        txtSubtotal.Text = ""
        txtTax.Text = ""
    End Sub

    Private Sub DroneDogsOrder_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'disable the result textfield subtotal,tax and OrderSubtotal
        txtSubtotal.Enabled = False
        txtTax.Enabled = False
        txtOrderSubtotal.Enabled = False
    End Sub
End Class

output;

DroneDogsOrder DRONEDOGS ORDER FORM The number of beef dogs ordered: The number of pork dogs The number of turkey dogs ordere

Add a comment
Know the answer?
Add Answer to:
If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use...

    PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use the following names for the project and solution, respectively: Chopkins Project and Chopkins Solution. Save the application in the VB2017\Chap03 folder. Change the form file's name to Main Form.vb. Change the form's name to frmMain. Create the interface shown in Figure 3-37. The interface contains six labels, three text boxes, and two buttons. The application calculates and displays the total number of packs ordered...

  • VISUAL BASIC (VISUAL STUDIO 2010) - PLEASE INCLUDE PICTURES OF OUTPUT AND CODE AND TEXTBOX pictures...

    VISUAL BASIC (VISUAL STUDIO 2010) - PLEASE INCLUDE PICTURES OF OUTPUT AND CODE AND TEXTBOX pictures of everything or thumbs downnnnnnn... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: VISUAL BASIC (VISUAL STUDIO 2010) - PLEASE INCLUDE PICTURES OF OUTPUT AND CODE AND TEXTBOX Be sur... VISUAL BASIC (VISUAL STUDIO 2010) - PLEASE INCLUDE PICTURES OF OUTPUT AND CODE AND TEXTBOX Be sure to include comments at the top of...

  • The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language....

    The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language. The book ISBN number that I am using is: 978-1-285-08416-9 or the UPC code is: 2-901285084168-1. Question 1 Visual Basic 2012 is an object-oriented programming language, which is a language that allows the programmer to use ____________________ to accomplish a program�s goal. Question 2 An application that has a Web user interface and runs on a server is called a(n) ____________________ application. Question 3...

  • Visual Basic Programming Step 1-2 not important, it's just file naming.

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

  • how to make this program for c++ visual studio 2015. Also, can I show your working...

    how to make this program for c++ visual studio 2015. Also, can I show your working and program. Also, Can you have notice for pseudo code? For the first problem, please implement Problem 4 on page 142 (p 143, 7E) of the text. A scan of the problem is provided below. This problem asks you to calculate the average rainfall for three months. The program should ask the user to enter the name of each month, such as June or...

  • Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for...

    Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for program with ALL conditions met. Conditions to be met: Word Problem A person inherits a large amount of money. The person wants to invest it. He also has to withdraw it annually. How many years will it take him/her to spend all of the investment that earns at a 7% annual interest rate? Note that he/she needs to withdraw $40,000.00 a year. Also there...

  • This is my question in Microsoft Visual Studio: In many settings, it is necessary to gather...

    This is my question in Microsoft Visual Studio: In many settings, it is necessary to gather input in forms sometimes in conjunction with a database but often also a standalone process. As we can see from the reading, many different controls exist to help gather input from a form. Using assignment operators, variables store information in RAM while the program executes. Write a form using multiple text boxes to gather input that includes: 1. the name of the patient 2....

  • Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels,...

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

  • C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable...

    C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable to transcribe this imageCHAPTER 3 Using Guy Objects and the Visual Studio IDE Using Gul Objects (continued) Forn click the Form, its Properties window appears in the lower right portion of the screen, and you can see that the Text property for the Form IS set to Forml. Take a moment to scroll through the list in the Properties Window, examining the values of...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT