In: Computer Science
In Visual Basic
Create an empty Web Site application named Bakery. Add a new Web page named Default.aspx to the application. Change the DOCUMENT object's Title property to Meyer's. The application should allow the user to enter two items: the number of doughnuts ordered and the number of muffins ordered. The application should should display the total number of items ordered and the total sales amount, inlcuding a 5% sales tax. A doughnut costs .50; a muffin costs .75. Save the application, and then start and test it.
Here a new Web Application Project in VB is created using Visual Studio 2017 with name "Bakery".This application contains a web page with name "Default.aspx".Below are the details of this page.
Default.aspx :
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Bakery._Default" %>
*****************************
Default.aspx.vb :
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
'Submit button click
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
Handles btnSubmit.Click
'taking entered value of doughnuts
Dim doughnuts As Integer = Integer.Parse(txtDoughnuts.Text)
'taking muffins value
Dim muffins As Integer = Integer.Parse(txtMuffins.Text)
'total items
Dim totalItems As Integer = doughnuts + muffins
'calculating amount
Dim Amount As Double = (doughnuts * 0.5) + (muffins * 0.75)
'calculating tax
Dim tax As Double = (Amount * 5) / 100
'calculating total amount
Dim totalAmount = Amount + tax
'displaying details on the label
lblResult.Text = "Total Items :" & totalItems & "
Amount without Tax : " & Amount & "
Tax : " & tax & "
Total Amount : " &
totalAmount
End Sub
End Class
======================================================
Output : Run application using F5 and will get the screen as shown below
Screen 1 :Default.aspx
Screen 2 :Enter items and click on calculate