Answer to Question #88992 in C# for Christopher Perez

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
1
Expert's answer
2019-05-02T13:26:58-0400
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!

Comments

Assignment Expert
01.05.20, 22:59

Dear David, If you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you. Price depends on complexity of your assignments and deadline. Please submit your assignments to our control panel and you'll get price estimation. If you have further questions please feel free to ask them via info@assignmentexpert.com (our support department) or use live chat on this website.

David
01.05.20, 02:24

I have asked a question already. Can someone send me the full code for this restaurant program? Id greatly appreciate it, thanks.

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS