Bakery project
Program plan:
- Create new Windows Forms Application.
- Design the form by placing the labels, textboxes, and buttons and then change their name and properties.
- Inside the “Calculate” button,
- Declare the required variables.
- Assign the name to the variable.
- Get the item price.
- Convert the string type values into a decimal value.
- Get the muffin price.
- Convert the string type values into a decimal value.
- Convert the string type values into the integer values
- Calculate the total item, subtotal of the item, sales tax, and total sales.
- Display the total amount, tax, and salesclerk’s name.
- Inside the “Clear Screen” button,
- Clear all the dates except date.
- Inside the “Exit” button,
- Close the form using “Me.Close” method
- Inside the “Print Receipt” button,
- Print the sales receipt.
- Inside the “ClearLabels”,
- Clear the calculated amounts.
This program is used to allow the user to enter the doughnut price, muffin price and then calculate the total items and total costs.
Explanation of Solution
Program:
'Definition of class frmMain
Public Class frmMain
'Definition of calculate
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' Declare the variables
Const strPROMPT As String = "Salesclerk's name:"
Const strTITLE As String = "Name Entry"
Const decTAX_RATE As Decimal = 0.02D
Dim intDonuts As Integer
Dim intMuffins As Integer
Dim intTotalItems As Integer
Dim decSubtotal As Decimal
Dim decSalesTax As Decimal
Dim decTotalSales As Decimal
Static strClerk As String
Static strDonutPrice As String
Static strMuffinPrice As String
Dim decDonutPrice As Decimal
Dim decMuffinPrice As Decimal
'Assign name to variable
strClerk = InputBox(strPROMPT, strTITLE, strClerk)
'Get item prices
strDonutPrice = InputBox("Doughnut price:", "Doughnut Price Entry", strDonutPrice)
'Convert the string type value into a decimal 'value
Decimal.TryParse(strDonutPrice, decDonutPrice)
'Get muffin price
strMuffinPrice = InputBox("Muffin price:", "Muffin Price Entry", strMuffinPrice)
'Convert the string type value into a decimal 'value
Decimal.TryParse(strMuffinPrice, decMuffinPrice)
'Convert the string type’s value into an 'integer values
Integer.TryParse(txtDonuts.Text, intDonuts)
Integer.TryParse(txtMuffins.Text, intMuffins)
'Calculate the total items
intTotalItems = intDonuts + intMuffins
'Calculate the subtotal
decSubtotal = intDonuts * decDonutPrice + intMuffins * decMuffinPrice
'Calculate the sales tax
decSalesTax = decSubtotal * decTAX_RATE
'Calculate the total sales
decTotalSales = decSubtotal + decSalesTax
'Display total amounts
lblTotalItems.Text = Convert.ToString(intTotalItems)
lblTotalSales.Text = decTotalSales.ToString("C2")
'Display tax and salesclerk's name
lblMsg.Text = "The sales tax was " &
decSalesTax.ToString("C2") & "." &
ControlChars.NewLine & strClerk
End Sub
'Definition of Clear button
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
'Clear calculated amounts
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
End Class
Output:
Enter the date, doughnuts, and muffins. Then click “Calculate” button.
Screenshot of “Meyer’s Purple Bakery” form
Enter the salesclerk name and then “OK” button.
Screenshot of “Name Entry” form
Enter the Doughnut price and then “OK” button.
Screenshot of “Doughnut Price Entry” form
Enter the muffin price and then “OK” button.
Screenshot of “Muffin Price Entry” form
Screenshot of “Meyer’s Purple Bakery” form
After clicking “Print Receipt” button the following window will appear:
Screenshot of “Print preview” form
After clicking “Clear Screen” button the entire textbox is cleared except date:
Screenshot of “Meyer’s Purple Bakery” form
Want to see more full solutions like this?
Chapter 3 Solutions
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
- True or False: Given the sets F and G with F being an element of G, is it always ture that P(F) is an element of P(G)? (P(F) and P(G) mean power sets). Why?arrow_forwardCan you please simplify (the domain is not empty) ∃xF (x) → ¬∃x(F (x) ∨ ¬G(x)). Foarrow_forwardHistogramUse par(mfrow=c(2,2)) and output 4 plots with different argument settings.arrow_forward
- (use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.arrow_forward1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).arrow_forwardScenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…arrow_forward
- make a screen capture showing the StegExpose resultsarrow_forwardWhich of the following is not one of the recommended criteria for strategic objectives? Multiple Choice a) realistic b) appropriate c) sustainable d) measurablearrow_forwardManagement innovations such as total quality, benchmarking, and business process reengineering always lead to sustainable competitive advantage because everyone else is doing them. a) True b) Falsearrow_forward
- Vision statements are more specific than strategic objectives. a) True b) Falsearrow_forwardThe three components of the __________ approach to corporate accounting include financial, environmental, and social performance measures. Multiple Choice a) stakeholder b) triple dimension c) triple bottom line d) triple efficiencyarrow_forwardCompetitors, as internal stakeholders, should be included in the stakeholder management consideration of a company and in its mission statement. a) True b) Falsearrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning