
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)
- Given a shared data set, we allow multiple readers to read at the same time, and only one single writer can access the shared data at the same time. In the lecture slides, a solution is given. However, the problem is that the write cannot write forever, if there are always at least one reader. How to ensure that the writer can eventually write? Propose your solution by using semaphores and implemented in Python from threading import Thread, Semaphore from time import sleep from sys import stdout class Reader(Thread): def__init__(self, name): self.n=name; Thread.__init__(self) defrun(self): globalnr, nw, dr, dw whileTrue: # ⟨await nw == 0 then nr += 1⟩ e.acquire() ifnw>0: #if nw > 0 or dw > 0 : dr+=1; e.release(); r.acquire() nr+=1 ifdr>0: dr-=1; r.release() else: e.release() # read data stdout.write(self.n+' reading\n') sleep(1) # ⟨nr -= 1⟩ e.acquire() nr-=1 ifnr==0anddw>0: dw-=1 ; w.release() else: e.release() class Writer(Thread): def__init__(self, name):…arrow_forwardAnnée scolaire: 2024/2025 Collège SMARA Devoir à domicile 1 semestre 2 Prof: NILAJ PHYSIQUE CHIMIE Nom et Prénom: Niveau: 3APIC Exercice 1: Durée: 1 heure 1) Donner la définition des termes suivantes? Le Mouvement : La vitesse moyenne: 2) Répondre par « Vrai » ou «> Un objet peut être en mouvement et au repos Si la vitesse est constante, le mouvement sera uniforme. 3) Compléter les phrases par les termes qui conviennent : Pour déterminer le mouvement ou le repos d'un objet, vous devez choisir un autre objet appelé le d'un point d'un corps mobile est l'ensemble des positions qu'il occupe durant son mouvement. Il y a trois types de trajectoires: circulaire. La distance de freinage dépend de 4) Cocher la bonne réponse? > La relation entre la vitesse, la distance et le temps: d Vm = dxt > L'unité internationale de la vitesse moyenne est : m/s 5) On considère la figure suivante : Compléter le tableau par les mots suivants : En mouvement au repos A C Km/h et et l' m. s-1 15 A B C Sol…arrow_forward5. Here is a tree corresponding to T(64) for an unknown recurrence relation: 32 + lg 64 8+ lg 16 2+ lg 4 2+lg4 2+lg4 8+ lg 16 2+lg4 7 7 7 7 7 7 7 7 Fill in the details for the corresponding recurrence relation: T(n) = T(n/4)+ T(1)= Put scratch work below. Scratch work is not graded but may be used for regrade partial credit.arrow_forward
- Top screenshot is question, the rest are examples and explinations.arrow_forwardActivity Time (days) Predecessors Earliest Expected Completion Time (TE) Latest Expected Completion Time (TE) 1 4 2 5 1 3456782222 6 1 7 1 4 4 6 2,3 5 3 5 5,7 9 4 7 10 3 6,9 11 5 8,9,10 12 4 11 Slack Critical Path? Yes or Noarrow_forwardI would like to know about the following concepts: 1. defragmentation 2. disk management 3. hardware RAIDarrow_forward
- Node.js, Express, and Nunjucks Templates?arrow_forwardCIT244 Program Project 3 Assignment As with any assigned program, do not wait until the last minute to start. Start early in the week the program is due so you can ask questions if you get stuck Node.js and Express and Nunjucks Templates We have gotten to the good stuff. There is a program similar to this assignment given as the last example in the lecture notes for the week that discusses node static files. This program will take more time that previous assignments. There are several examples you should study first, particularly the pizza order example program available in the examples programs folder for the week discussing static files. You should study and run the pizza order program before trying this program. The pseudo-company is called Sun or Fun, which offers cheap flights from Louisville to either Miami or Vegas. Here's a video of how it should work. NOTE: You will hear or see references to Handlebars in this video. We used to use Handlebars, but it will be Nunjucks that we…arrow_forwardhow to write the expression for the outputarrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
