// Programmer: Janet Joy // A program to calculate price of meal at a buffet restaurant. // Uses 2 groups of radio buttons to select meal and age group. // A check box is checked if the customer has a $1 off coupon. 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 Buffet { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void radBreakfast_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void calculatePrice() { // Breafast is $10, lunch $14 and dinner is $18. double basePrice; if (radBreakfast.Checked) basePrice = 10; else if (radLunch.Checked) basePrice = 14; else basePrice = 18; // Children pay half price. if (radChild.Checked) basePrice = basePrice * 0.5; // Seniors get a 20% discount, thus they pay 80% if (radSenior.Checked) basePrice = basePrice * 0.8; // If they have a coupon they get $1 off. if (chkCoupon.Checked) basePrice -= 1; // Price is displayed to 2 decimal places. lblPrice.Text = basePrice.ToString("$0.00"); } private void radLunch_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void radDinner_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void chkCoupon_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void radChild_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void radAdult_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } private void radSenior_CheckedChanged(object sender, EventArgs e) { calculatePrice(); } } }