In: Computer Science
Using C#: Create a Form that consists of 4 checkboxes, three radio buttons, a label and a button. The 4 checkboxes represent pizza toppings. The three radiobuttons should represent three sizes of pizza, namely “small”, “medium” and “large”. When the user clicks the button you need to calculate the price of the pizza. The calculation should be done as follows: count up the cost of the selected ingredients (you may assign your own prices for the ingredients) and then multiply this cost with 1 for a medium, 0.5 for a small and 2 for a large. Display the calculated price in the label.
Code
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 Pizza_Ordering
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnPlaceOrder_Click(object sender, EventArgs
e)
{
double totalCost = 0;
if (chkCheez.Checked == true)
{
totalCost += 2.5;
}
if (chkPaper.Checked == true)
{
totalCost += 5.0;
}
if (chkBeacon.Checked == true)
{
totalCost += 2;
}
if (chkBlackBeacon.Checked == true)
{
totalCost += 7.5;
}
if (rdSmall.Checked == true)
{
totalCost *= 0.5;
}
else if (rdMedium.Checked == true)
{
totalCost *= 1;
}
else
{
totalCost *= 2;
}
lblCost.Text = totalCost.ToString("C");
}
}
}
design
outputs
If you have any query regarding the code please ask me in the
comment i am here for help you. Please do not direct thumbs down
just ask if you have any query. And if you like my work then please
appreciates with up vote. Thank You.