(Restaurant Bill Calculator) A restaurant wants an app that calculates a table’s bill. The app should display all the menu items from Fig. 15.53 in four ComboBoxes. Each ComboBox should contain a category of food offered by the restaurant (Beverage, Appetizer, Main Course and Dessert).
The user can choose from one of these ComboBoxes to add an item to a table’s bill. As each item is selected in the ComboBoxes, add the price of that item to the bill. The user can click the Clear Bill Button to restore the Subtotal:, Tax: and Total: fields to $0.00.
Solution:
The user can choose from one of these ComboBoxes to add an item to a table’s bill. As each item is selected in the ComboBoxes, add the price of that item to the bill. The user can click the Clear Bill Button to restore the Subtotal:, Tax: and Total: fields to $0.00.
Solution:
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 Q4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
double total = 0;
double subtotal = 0;
double tax = 0;
if (comboBox1.SelectedIndex == 0)
{
subtotal = subtotal + 400;
}
if (comboBox1.SelectedIndex == 1)
{
subtotal = subtotal + 50;
}
if (comboBox1.SelectedIndex == 2)
{
subtotal = subtotal + 300;
}
if (comboBox2.SelectedIndex == 0)
{
subtotal = subtotal + 400;
}
if (comboBox2.SelectedIndex == 1)
{
subtotal = subtotal + 50;
}
if (comboBox2.SelectedIndex == 2)
{
subtotal = subtotal + 300;
}
if (comboBox3.SelectedIndex == 0)
{
subtotal = subtotal + 400;
}
if (comboBox3.SelectedIndex == 1)
{
subtotal = subtotal + 50;
}
if (comboBox3.SelectedIndex == 2)
{
subtotal = subtotal + 300;
}
textBox7.Text = Convert.ToString(subtotal);
tax = subtotal * 0.2;
textBox8.Text = Convert.ToString(tax);
total = tax + subtotal;
textBox9.Text = Convert.ToString(total);
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Post A Comment:
0 comments: