Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application that can be used in a restaurant to calculate a table’s bi

ID: 3672590 • Letter: C

Question

Create an application that can be used in a restaurant to calculate a table’s bill. The program should display all the menu items from the table below in 4 Combo boxes. There are 4 categories of food offered which are Beverage, Appetizer, Main Course and Desert. Each Combo box should carry one of the food categories. The user can choose from the Combo box to add an item to a table’s bill. When each item is selected from the Combo box, the item price will be added to the bill. The Clear Bill button allows user to reset the Subtotal, Tax and Total to 0. See the following UI for your design reference. Use 10% as the tax rate. Create a new project (Windows Forms Application) and name it FirstName_LastName_A3 where FirstName is your first name and LastName is your last name. Zip your project folder and submit it in Eagle online for grading.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Bill
{
public partial class RestaurantBill : Form
{
public RestaurantBill()
{
InitializeComponent();
}

Dictionary<string, float> prices;

/* Is callen when the form is displayed for the first time */
private void Form_Load(object sender, EventArgs e)
{
/* Filling up comboboxes */
Beverage.Items.AddRange(new string[] { "Coffee", "Tea", "Juice" });
Appetizers.Items.AddRange(new string[] { "Pepperoni Bread", "Chicken Quesadilla", "Potato Skins", "Battered Mushrooms" });
Maincourses.Items.AddRange(new string[] { "Vegertarian Linguini", "Sirloin Steak", "Fillet of Venison", "Chicken Salad on Croissant", "Spaghetti with Fresh Spinach" });
Desserts.Items.AddRange(new string[] { "Berry Crumble", "Coconut-cream pie", "Banana Split" });

/* Setting up foods' prices */
prices = new Dictionary<string, float>();
prices["Coffee"] = 4.55f;
prices["Tea"] = 3.15f;
prices["Juice"] = 6.40f;

prices["Pepperoni Bread"] = 19.0f;
prices["Chicken Quesadilla"] = 2.92f;
prices["Potato Skins"] = 6.10f;
prices["Battered Mushrooms"] = 4.85f;

prices["Vegertarian Linguini"] = 15.55f;
prices["Sirloin Steak"] = 23.20f;
prices["Fillet of Venison"] = 40.90f;
prices["Chicken Salad on Croissant"] = 9.31f;
prices["Spaghetti with Fresh Spinach"] = 12.70f;

prices["Berry Crumble"] = 6.40f;
prices["Coconut-cream pie"] = 7.88f;
prices["Banana Split"] = 5.06f;
}

private void Calculate_Click(object sender, EventArgs e)
{
float subtotal = 0;
float tax;
float total;

/* Summing ordered foods prices */
foreach (string food in OrderedFoods.Items)
subtotal += prices[food];

tax = subtotal * 0.05f; //tax percent (0.05) could be different
total = subtotal + tax;

LSubtotal.Text = "Subtotal: " + subtotal.ToString();
LTax.Text = "Tax: " + tax.ToString();
LTotal.Text = "Total: " + total.ToString();
}

private void Clear_Click(object sender, EventArgs e)
{
OrderedFoods.Items.Clear();
LSubtotal.Text = "Subtotal: ";
LTax.Text = "Tax: ";
LTotal.Text = "Total: ";
}

private void BAdd_Click(object sender, EventArgs e)
{
OrderedFoods.Items.Add(Beverage.SelectedItem);
}

private void AAdd_Click(object sender, EventArgs e)
{
OrderedFoods.Items.Add(Appetizers.SelectedItem);
}

private void MAdd_Click(object sender, EventArgs e)
{
OrderedFoods.Items.Add(Maincourses.SelectedItem);
}

private void DAdd_Click(object sender, EventArgs e)
{
OrderedFoods.Items.Add(Desserts.SelectedItem);
}
}
}


Restaurant Bill.Designer.cs
namespace Bill
{
partial class RestaurantBill
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.Beverage = new System.Windows.Forms.ComboBox();
this.Appetizers = new System.Windows.Forms.ComboBox();
this.Desserts = new System.Windows.Forms.ComboBox();
this.Maincourses = new System.Windows.Forms.ComboBox();
this.Calculate = new System.Windows.Forms.Button();
this.LSubtotal = new System.Windows.Forms.Label();
this.LTax = new System.Windows.Forms.Label();
this.LTotal = new System.Windows.Forms.Label();
this.OrderedFoods = new System.Windows.Forms.ListBox();
this.BAdd = new System.Windows.Forms.Button();
this.AAdd = new System.Windows.Forms.Button();
this.MAdd = new System.Windows.Forms.Button();
this.DAdd = new System.Windows.Forms.Button();
this.Clear = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// Beverage
//
this.Beverage.FormattingEnabled = true;
this.Beverage.Location = new System.Drawing.Point(12, 12);
this.Beverage.Name = "Beverage";
this.Beverage.Size = new System.Drawing.Size(121, 21);
this.Beverage.TabIndex = 0;
//
// Appetizers
//
this.Appetizers.FormattingEnabled = true;
this.Appetizers.Location = new System.Drawing.Point(12, 39);
this.Appetizers.Name = "Appetizers";
this.Appetizers.Size = new System.Drawing.Size(121, 21);
this.Appetizers.TabIndex = 1;
//
// Desserts
//
this.Desserts.FormattingEnabled = true;
this.Desserts.Location = new System.Drawing.Point(12, 93);

I AM HAVING THE CODE THIS IN COMPRESED FOLDER BUT I CANT ATTACH HERE IF U SEND UR MAIL I VL ATTACH IT TO YOUR MAIL.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote