Bakery application
Program plan:
- Create new Windows Forms Application.
- Design the form by placing the labels, textbox, and button and then change their name and properties.
- Inside the “Calculate” button,
- Declare required variables.
- Assign the name to the variables.
- Calculate the items sold.
- Calculate the sub total
- Calculate the sales tax.
- Display total amounts.
- Display tax and sales clerk’s name.
- Inside the “Exit” button,
- Close the form.
- Inside the “btnPrint_Click”
- Print the sales receipt.
- Inside the “txtDate_Enter”
- Select all the values.
- Inside the “txtDate_keyPress”,
- Check the condition.
- Inside the “txtDonuts_Enter”,
- Select all the text.
- Inside the “CancelKeys”,
- Check the condition.
- Inside the “txtMuffins_Enter”,
- Select all the text.
This program is to modify the bakery application.
Explanation of Solution
Program:
'Definition of class frmMain
Public Class frmMain
'Definition of button calculate
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' Calculate number of items sold and total sales
Const PromtMsg As String = "Salesclerk's name:"
Const title As String = "Name Entry"
Const ItemPrice As Decimal = 0.5D
Const tax As Decimal = 0.02D
Dim donuts As Integer
Dim muffins As Integer
Dim totalItems As Integer
Dim subTotal As Decimal
Dim salesTax As Decimal
Dim totalSales As Decimal
Static clerk As String
'Assign the name to variable
clerk = InputBox(PromtMsg, title, clerk)
' Calualte the items sold
Integer.TryParse(txtDonuts.Text, donuts)
Integer.TryParse(txtMuffins.Text, muffins)
totalItems = donuts + muffins
' calculate the subtotal
subTotal = totalItems * ItemPrice
' calculate the sales tax
salesTax = subTotal * tax
' calculate the total sales
totalSales = subTotal + salesTax
' display total amounts
lblTotalItems.Text = Convert.ToString(totalItems)
lblTotalSales.Text = totalSales.ToString("C2")
' display tax and salesclerk's name
lblMsg.Text = "The sales tax was " &
salesTax.ToString("C2") & "." &
ControlChars.NewLine & clerk
End Sub
'Definition of button clear
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
'Assign text box to empty
txtDonuts.Text = String.Empty
txtMuffins.Text = String.Empty
lblTotalItems.Text = String.Empty
lblTotalSales.Text = String.Empty
lblMsg.Text = String.Empty
' send the focus to the Doughnuts box
txtDonuts.Focus()
End Sub
'Definition of button exit
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Close the form
Me.Close()
End Sub
'Definition of button print
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
'print the sales receipt
btnCalc.Visible = False
btnClear.Visible = False
btnExit.Visible = False
btnPrint.Visible = False
PrintForm1.Print()
btnCalc.Visible = True
btnClear.Visible = True
btnExit.Visible = True
btnPrint.Visible = True
End Sub
'Definition of ClearLabels
Private Sub ClearLabels(sender As Object, e As EventArgs) _
Handles txtDonuts.TextChanged, txtMuffins.TextChanged
' Clear the total items, total sales, and message
lblTotalItems.Text = String.Empty
lblTotalSales.Text = String.Empty
lblMsg.Text = String.Empty
End Sub
'Definition of txtDate_Enter
Private Sub txtDate_Enter(sender As Object, e As EventArgs) Handles txtDate.Enter
'Select all the values
txtDate.SelectAll()
End Sub
'Defintion of txtDate_keyPress
Private Sub txtDate_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDate.KeyPress
'Check the conditon
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> "/" AndAlso e.KeyChar <> "-" AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
'Definition of txtDonuts_Enter
Private Sub txtDonuts_Enter(sender As Object, e As EventArgs) Handles txtDonuts.Enter
'Select all the text
txtDonuts.SelectAll()
End Sub
'Defintion of CancelKeys
Private Sub CancelKeys(sender As Object, e As KeyPressEventArgs) Handles txtDonuts.KeyPress, txtMuffins.KeyPress
'Check the condition
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
'Definition of txtMuffins_Enter
Private Sub txtMuffins_Enter(sender As Object, e As EventArgs) Handles txtMuffins.Enter
'Select all the text
txtMuffins.SelectAll()
End Sub
End Class
Run the program, enter the date, number of Doughnuts and Muffins and then click on the “Calculate” button.
Screenshot of form
Want to see more full solutions like this?
Chapter 4 Solutions
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
- Write a tkinter application that asks the user to create their own pizza. First, they should enter their name. Then, allow them to pick one of three crusts (thin, regular, deep dish), one of three sauces (Regular, BBQ, Alfredo), and any number of 3 toppings (Pepperoni, Olives, Mushroom). They should also pick if they want a small, medium, or large pizza. When the submit button is clicked, calculate the total cost ($10 base price, $0.50 for each topping, and $1.50 for each increase in size larger than small). Once the total is calculated, display a messagebox that thanks the user (by name) for their order and prints out the total cost.arrow_forwardCreate an application with a form that resembles Figure 3-48. The PictureBox controls display the images of four fruits (a banana, an apple, an orange, and a pear) and each fruit’s calories. You can find these images in the Chap3 folder of the Student Sample Programs. When the application starts, the total calories should be zero. Each time the user clicks one of the PictureBoxes, the calories for the fruit should be added to the total calories, and the total calories should be displayed. When the user clicks the Reset button, the total calories should be reset to zero. Hello, I recently sent this question, but didn't provide images as needed. I apologize for that, I'm not sure how to upload the other three fruits (an apple, an orange, and a pear) since I can only upload two. If there is a way, please let me know. Just for clarification on this question, everytime the PictureBox (fruit) is clicked on, it will display the fruits calories on the label under "Total Calories", and…arrow_forwardFor this Mini-project, you need to create an application that allows the user to input two decimal numbers. The application should also have buttons that allow the user to request that the numbers are added, subtracted, multiplied, or divided. In addition, give an option to complete all 4 calculations or to clear the input and output (i.e., reset the page to its starting state). The program is written in C# in Visual Studio using the Web Form Design. Thank you!arrow_forward
- In Visual Basic, when you drag a field object to an existing control in the interface, Visual Basic replaces the current control with the newly created control. True or false? a. True b. Falsearrow_forwardQuestion 1 Get room rate Room type single Number of night 3 Room rate 750.00 Get rate Close Figure 2: Get room rate GUI Write a complete program to create a graphical user interface (GUI) which calculate the room rate according to Table 1. The program should calculate and show the room rate in a text field which is not editable when the Get rate button is pressed and the system will be terminated when the Close button is pressed. The size of GUI should be set as 300 x 250. It should be shown in the centre of the screen and the program should shutdown when the user press the close button on the top right corner. Lastly, remember to create an object for the class in a main() method. Table 1: Hotel room rate according to room type Room type single Price in RM (per night) 250 double 320 suite 500arrow_forwardIn this exercise, you modify the Grade Calculator application from this chapter’s Apply lesson. Use Windows to make a copy of the Grade Solution folder. Rename the copy Grade Solution-Intermediate. Open the Grade Solution.sln file contained in the Grade Solution-Intermediate folder. Open the CourseGrade.vb file. The DetermineGrade method should accept an integer that represents the total number of points that can be earned in the course. (Currently, the total number of points is 200: 100 points per test.) For an A grade, the student must earn at least 90% of the total points. For a B, C, and D grade, the student must earn at least 80%, 70%, and 60%, respectively. If the student earns less than 60% of the total points, the grade is F. Make the appropriate modifications to the DetermineGrade method and then save the solution. Unlock the controls on the form. Add a label control and a text box to the form. Change the label control’s Text property to “&Maximum points:” (without the quotation marks). Change the text box’s name to txtMax. Lock the controls and then reset the tab order. Open the form’s Code Editor window. The txtMax control should accept only numbers and the Backspace key. Code the appropriate procedure. The grade should be cleared when the user makes a change to the contents of the txtMax control. Code the appropriate procedure. Modify the frmMain_Load procedure so that each list box displays numbers from 0 through 200. Locate the btnDisplay_Click procedure. If the txtMax control does not contain a value, display an appropriate message. The maximum number allowed in the txtMax control should be 400; if the control contains a number that is more than 400, display an appropriate message. The statement that calculates the grade should pass the maximum number of points to the studentGrade object’s DetermineGrade method. Make the necessary modifications to the procedure. Save the solution and then start and test the application.arrow_forward
- After you have dragged a Button onto a Form in the IDE, you can double-click it to __________ delete it view its properties create a method that executes when a user clicks the Button increase its sizearrow_forwardWhen a form has been modifi ed since the last time it was saved, whatappears on its tab in the designer window?arrow_forwardThe below form will represent the main form from which the user will navigate to the other forms. Meaning each button should be linked to the appropriate form. E.g. If button Manage Addresses is clicked the form managed addresses should be displayed. The Exit button should successfully terminate the program. Create a void method for each button and name them as follow: LinkToAddresses (), LinkToCustomers (), LinkToDrivers (), LinkToStatus (), and LinkToFreight (). The methods should be called under the appropriate button. For the exit button create a void method named AppExit () this should terminate the program.arrow_forward
- We have the following control objects: txtFirst, txtLast, IbIName, and btnName. When the user click btnName, first name followed by last name should appear on IbIName, the code is: Select one: IbIName.Text = System.Concatinate(txtFirst.Text, txtLast.Text); %3D Forml.lbIName = txtFirst + txtLast; IbIName.Text = txtFirst.Text + " " + txtLast.Text; IblName.Text = Forml.Concatinate(txtFirst, txtLast);arrow_forwardPlease____Call the display method with car1 object..arrow_forwarduse java GUI The form should contain five command buttons, two labels only, and three picture boxes. The three picture boxes, each containing a flag, are on top of one another, but only one should be visible at a time. For each picture box: Be sure to add the image as a local resource. Set the Size property to 100, 50 Click the Size Mode list arrow, then click StretchImage in the list. For the Labels: One label will have your name as the programmer – see bottom left corner of the windows above. The other label will be used to display the name of the capital city. When a country button is clicked assign the name of the city into this label.arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT