Question #88992

A restaurant wants an application that calculates a table’s bill.
The application should let user enter the number of people in the party. If it is more than 6, it adds 15% tips to the total. Otherwise, let user enter the tips amount.
The application should display all the menu items in a ListBox (ComboBox). The ListBox (ComboBox) should Display the category of food offered by the restaurant separately (Beverage, Appetizer, Main Course and Dessert). The user can choose from one of the ListBox (ComboBox) to add an item to a table’s bill. As each item is selected, it adds the price of that item to the subtotal.
The program should include Subtotal, Tax, Tips, and Total fields in the GUI. Also, the user can click the “Clear Bill” Button to restore the Subtotal, Tax, Tips, and Total to $0.00.
The application should allow the user to modify the menu items in the database (update, delete and add).
Use the RestaurantMenu database

Expert's answer

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


namespace RestourantMenu
{
    public partial class Form1 : Form
    {
        private float subtotal = 0;
        private float tax = 0;
        private float tips = 0;
        private float total = 0;
        private int peopleCount = 0;
        private bool fifteenthPercentToTips = false;


        public Form1()
        {
            InitializeComponent();
        }


        private void ButtonAddToBillTable_Click(object sender, EventArgs e)
        {
            if (treeViewFood.SelectedNode.Parent != null)
                listBoxTableBill.Items.Add(treeViewFood.SelectedNode.Text);
        }


        private void ButtonClear_Click(object sender, EventArgs e)
        {
            textBoxSubtotal.Text = "0.00$";
            textBoxTax.Text = "0.00$";
            textBoxTips.Text = "0.00$";
            textBoxTotal.Text = "0.00$";
        }


        private void ButtonEnterPeopleCount_Click(object sender, EventArgs e)
        {
            if (Int16.TryParse(textBoxPeopleCount.Text, out short n))
            {
                peopleCount = n;
                if (peopleCount <= 6)
                {
                    textBoxTipsCount.Enabled = true;
                    buttonTipsCount.Enabled = true;
                }
                else
                    fifteenthPercentToTips = true;
            }
            else
            {
                MessageBox.Show("Write correct number of people in party!");
                textBoxTipsCount.Enabled = false;
                buttonTipsCount.Enabled = false;
                fifteenthPercentToTips = false;
            }
        }


        private void ButtonTipsCount_Click(object sender, EventArgs e)
        {
            if (float.TryParse(textBoxTipsCount.Text.Replace('.',','), out float n))
            {
                tips = n;
                textBoxTips.Text = tips.ToString("0.00") +"$";
            }
            else
                MessageBox.Show("Write correct value of tips!");
        }
    }
}


Please submit your question as order to get the full Visual Studio project.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS