# (Solved Homework): C# Windows form please, Thank you guys again for all your awesome help. I'm stuck on the coding for the groupboxes,

C# Windows form please, Thank you guys again for all your awesome help.

I’m stuck on the coding for the groupboxes, and doing the mathematical calculations at the end to add up all the totals.

In this exercise, you’ll complete a form that accepts a lunch order from the user and then calculates the order subtotal and total.

The application should provide for these main courses and add-ons:

Hamburger                   6.95                                   Lettuce, tomato, and onions              .75

Ketchup, mustard, and mayo
French fries

Pizza                              5.95                                 Pepperoni                                              .50
Sausage
Olives

Bacon bits

1.       Open the LunchOrderStart project in the Assignment8EX2_LunchOrder directory.

2.       Add three radio buttons to the Main Course group box, and set their properties so they appear as shown above.

·         The Hamburger option should be selected by default.

3.       Add a group box for the add-on items. Then, add three check boxes to this group box as shown above.

·         None of the check boxes should be selected by default.

4.       Code a method name ClearTotals that clears the three text boxes and a method named ClearAddOns that removes the check marks from the three check boxes.

5.       Code an event handler that changes the text that’s displayed for the Add-ons group box and the three check boxes when the user selects a different main course.

·         This event handler should also remove the check marks from the add-ons and clear the order totals. Test the application to be sure this works correctly.

6.       Code an event handler that calculates and displays the subtotal, tax, and order total when the user clicks the Place Order button.

·         The subtotal is the cost of the main course plus the cost of the add-ons. The tax is 7.75% of the subtotal. And the order total is the subtotal plus the tax.

·         Test the application to be sure this works correctly.

7.       Code an event handler that clears the order totals when the user checks or unchecks an add-on. Then, test the application one more time.

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

namespace LunchOrder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const decimal SalesTaxPct = 0.0775m;

//     private void btnPlaceOrder_Click(object sender, EventArgs e)
//     {
//…
//     }

//       private void MainCourse_CheckedChanged(object sender, EventArgs e)
//       {
//…
//       }

//        private void ClearTotals()
//        {
//…
//        }

//        {
//…
//        }

//        private void ChangeAddOns(object sender, EventArgs e)
//…
//        }
private void btnExit_Click(object sender, EventArgs e)
{
Close();
}

}
}

Lunch Order.Designer.cs

namespace Lunch_Order
{
partial class frmLunchOrderForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name=”disposing”>true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support – do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.grpBoxText = new System.Windows.Forms.GroupBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.chkPizza = new System.Windows.Forms.CheckBox();
this.chkHamburger = new System.Windows.Forms.CheckBox();
this.btnSubmit = new System.Windows.Forms.Button();
this.lblSubTotal = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblOrToal = new System.Windows.Forms.Label();
this.lbltX = new System.Windows.Forms.Label();
this.lblSubTo = new System.Windows.Forms.Label();
this.lblOrderTotal = new System.Windows.Forms.Label();
this.lblTax = new System.Windows.Forms.Label();
this.btnExit = new System.Windows.Forms.Button();
this.btnClearOrder = new System.Windows.Forms.Button();
this.lboxOrderSummary = new System.Windows.Forms.ListBox();
this.fontDialog1 = new System.Windows.Forms.FontDialog();
this.btnTexFont = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.grpBoxText.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// grpBoxText
//
this.grpBoxText.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grpBoxText.ForeColor = System.Drawing.SystemColors.HotTrack;
this.grpBoxText.Location = new System.Drawing.Point(193, 42);
this.grpBoxText.Name = “grpBoxText”;
this.grpBoxText.Size = new System.Drawing.Size(231, 114);
this.grpBoxText.TabIndex = 4;
this.grpBoxText.TabStop = false;
//
//
this.chkadd_On_OnOne.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
//
//
this.chkAdd_On_Three.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
//
//
this.chkadd_On_Two.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(12, 42);
this.groupBox1.Name = “groupBox1”;
this.groupBox1.Size = new System.Drawing.Size(175, 116);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = “Main Course”;
//
//
this.chkSalad.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
//
// chkPizza
//
this.chkPizza.AutoSize = true;
this.chkPizza.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.chkPizza.Location = new System.Drawing.Point(13, 45);
this.chkPizza.Name = “chkPizza”;
this.chkPizza.Size = new System.Drawing.Size(109, 22);
this.chkPizza.TabIndex = 1;
this.chkPizza.Text = “Pizza -\$5.95”;
this.chkPizza.UseVisualStyleBackColor = true;
this.chkPizza.Click += new System.EventHandler(this.itemSelected);
//
// chkHamburger
//
this.chkHamburger.AutoSize = true;
this.chkHamburger.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.chkHamburger.Location = new System.Drawing.Point(13, 19);
this.chkHamburger.Name = “chkHamburger”;
this.chkHamburger.Size = new System.Drawing.Size(146, 22);
this.chkHamburger.TabIndex = 0;
this.chkHamburger.Text = “Hamburger -\$6.95”;
this.chkHamburger.UseVisualStyleBackColor = true;
this.chkHamburger.Click += new System.EventHandler(this.itemSelected);
//
// btnSubmit
//
this.btnSubmit.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnSubmit.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSubmit.Location = new System.Drawing.Point(299, 174);
this.btnSubmit.Name = “btnSubmit”;
this.btnSubmit.Size = new System.Drawing.Size(111, 27);
this.btnSubmit.TabIndex = 3;
this.btnSubmit.Text = “Place Order”;
this.btnSubmit.UseVisualStyleBackColor = true;
this.btnSubmit.Click += new System.EventHandler(this.placeOrder_Click);
//
// lblSubTotal
//
this.lblSubTotal.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblSubTotal.Location = new System.Drawing.Point(120, 16);
this.lblSubTotal.Name = “lblSubTotal”;
this.lblSubTotal.Size = new System.Drawing.Size(100, 23);
this.lblSubTotal.TabIndex = 9;
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(12, 174);
this.groupBox2.Name = “groupBox2”;
this.groupBox2.Size = new System.Drawing.Size(254, 120);
this.groupBox2.TabIndex = 10;
this.groupBox2.TabStop = false;
this.groupBox2.Text = “Order Total”;
//
// lblOrToal
//
this.lblOrToal.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblOrToal.Location = new System.Drawing.Point(34, 71);
this.lblOrToal.Name = “lblOrToal”;
this.lblOrToal.Size = new System.Drawing.Size(80, 23);
this.lblOrToal.TabIndex = 10;
this.lblOrToal.Text = “Order Total:”;
//
// lbltX
//
this.lbltX.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbltX.Location = new System.Drawing.Point(36, 48);
this.lbltX.Name = “lbltX”;
this.lbltX.Size = new System.Drawing.Size(78, 23);
this.lbltX.TabIndex = 10;
this.lbltX.Text = “Tax(7.75%):”;
//
// lblSubTo
//
this.lblSubTo.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblSubTo.Location = new System.Drawing.Point(47, 16);
this.lblSubTo.Name = “lblSubTo”;
this.lblSubTo.Size = new System.Drawing.Size(67, 23);
this.lblSubTo.TabIndex = 10;
this.lblSubTo.Text = “SubTotal:”;
//
// lblOrderTotal
//
this.lblOrderTotal.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblOrderTotal.Location = new System.Drawing.Point(120, 70);
this.lblOrderTotal.Name = “lblOrderTotal”;
this.lblOrderTotal.Size = new System.Drawing.Size(100, 23);
this.lblOrderTotal.TabIndex = 9;
//
// lblTax
//
this.lblTax.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblTax.Location = new System.Drawing.Point(120, 43);
this.lblTax.Name = “lblTax”;
this.lblTax.Size = new System.Drawing.Size(100, 23);
this.lblTax.TabIndex = 9;
//
// btnExit
//
this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnExit.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnExit.Location = new System.Drawing.Point(299, 244);
this.btnExit.Name = “btnExit”;
this.btnExit.Size = new System.Drawing.Size(111, 27);
this.btnExit.TabIndex = 5;
this.btnExit.Text = “Exit”;
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnClearOrder
//
this.btnClearOrder.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClearOrder.Location = new System.Drawing.Point(299, 210);
this.btnClearOrder.Name = “btnClearOrder”;
this.btnClearOrder.Size = new System.Drawing.Size(111, 27);
this.btnClearOrder.TabIndex = 4;
this.btnClearOrder.Text = “New Order”;
this.btnClearOrder.UseVisualStyleBackColor = true;
this.btnClearOrder.Click += new System.EventHandler(this.newOrders_Click);
//
// lboxOrderSummary
//
this.lboxOrderSummary.FormattingEnabled = true;
this.lboxOrderSummary.Location = new System.Drawing.Point(450, 46);
this.lboxOrderSummary.Name = “lboxOrderSummary”;
this.lboxOrderSummary.Size = new System.Drawing.Size(188, 238);
this.lboxOrderSummary.TabIndex = 6;
//
// btnTexFont
//
this.btnTexFont.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnTexFont.Location = new System.Drawing.Point(299, 277);
this.btnTexFont.Name = “btnTexFont”;
this.btnTexFont.Size = new System.Drawing.Size(111, 26);
this.btnTexFont.TabIndex = 13;
this.btnTexFont.Text = “Change Text Font”;
this.btnTexFont.UseVisualStyleBackColor = true;
this.btnTexFont.Visible = false;
this.btnTexFont.Click += new System.EventHandler(this.btnTexFont_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = “label1”;
this.label1.Size = new System.Drawing.Size(207, 20);
this.label1.TabIndex = 14;
this.label1.Text = “Momo Johnson Project 10-2”;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(446, 23);
this.label2.Name = “label2”;
this.label2.Size = new System.Drawing.Size(135, 20);
this.label2.TabIndex = 15;
this.label2.Text = “Receipt Summary”;
//
// frmLunchOrderForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(666, 315);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = “frmLunchOrderForm”;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = “Lunch Order”;
this.grpBoxText.ResumeLayout(false);
this.grpBoxText.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion
private System.Windows.Forms.GroupBox grpBoxText;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Label lblSubTotal;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label lblSubTo;
private System.Windows.Forms.Label lbltX;
private System.Windows.Forms.Label lblTax;
private System.Windows.Forms.Label lblOrderTotal;
private System.Windows.Forms.Label lblOrToal;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.CheckBox chkPizza;
private System.Windows.Forms.CheckBox chkHamburger;
private System.Windows.Forms.Button btnClearOrder;
private System.Windows.Forms.ListBox lboxOrderSummary;
private System.Windows.Forms.FontDialog fontDialog1;
private System.Windows.Forms.Button btnTexFont;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}
}

Lunch Order.cs

using System;

using System.Windows.Forms;

/*
This application calculates the sub-total, tax and order total of the lunch order by a
client.
*/

namespace Lunch_Order
{
public partial class frmLunchOrderForm : Form

{
String value;
double hamburger = 0, pizza, salad;

public frmLunchOrderForm()
{
InitializeComponent();
}

//A event handler that adds the various add-on items price selected by the user
private void addOnItems(object sender, EventArgs e)
{
//Converting the sender to a checkbox and then to a String
//Calling to various methods to calculate the add-on of each item selected by the user

}

//An action event for the hamburger, pizza and salad checkbox
private void itemSelected(object sender, EventArgs e)
{
bool chikcHamburger = chkHamburger.Checked;
CheckBox button = (CheckBox)sender;
value = button.Text;
hamburger = getMainCoursePrice(chkHamburger, 6.95);
pizza = getMainCoursePrice(chkPizza, 5.95);
//Set the UIs to not visible
setVisibilityUIs(false, false, false);
//Uncheck various UIs if they are checked
unCheckCheckBox();
//set the Various UIs string to empty string
setVisibleUIs(“”, “”, “”, “”);

//Setting the various checkbox add-Ons controls if the check hamburger, pizza or salad.
if (chkHamburger.Checked)
{
//Setting the string value of various UIs using the setVisibleUIs method
setVisibleUIs(“Lettuce, tomato, and onions”, “Mayonnaise and mustard”, “French fries”, “Add-on items \$.75/each”);
setVisibilityUIs();//setting the visibility of the UIs using the setVisibilityUIs method
}

//If Pizza checkbox is checked set the string of each UIs controls
if (chkPizza.Checked)
{

setVisibleUIs(” Pepperoni”, “Sausage”, ” Olives”, “Add-on items \$.50/each”);
setVisibilityUIs();
}

//If the salad checkbox is clicked display the UIs and set its visibility
{
setVisibilityUIs();
}
}
//A method that gets the total tax of the items being purchaseed
private double getTax(double number, double taxNumber)
{
return number * taxNumber;
}
//A method that set the text of the various UIs.
{

}
//A Method that sets the visibility of various add-on check box
private void setVisibilityUIs(bool a = true, bool b = true, bool c= true)
{
}
//A method tha clears the sub-Total, tax and order Total text box
private void clear()
{
lblOrderTotal.Text = “”;
lblSubTotal.Text = “”;
lblTax.Text = “”;

}
//A Method that clears the various controls and variables when the new order button is clicked
private void newOrders_Click(object sender, EventArgs e)
{
lblOrderTotal.Text = “”;
lblSubTotal.Text = “”;
lblTax.Text = “”;
lboxOrderSummary.Items.Clear();
//Set the UIs to not visible
setVisibilityUIs(false, false, false);
//Uncheck various UIs if they are checked
unCheckCheckBox();
//set the Various UIs string to empty string
setVisibleUIs(“”, “”, “”, “”);
hamburger = 0;
pizza = 0;
unCheckCheckBox();
unCheckMainCourse();
}

//A method that changes the fonts of the listbox text. Extra features added by me
private void btnTexFont_Click(object sender, EventArgs e)
{
if(fontDialog1.ShowDialog() == DialogResult.OK)
{
lboxOrderSummary.Font = fontDialog1.Font;
}
}
//A method that exits the form when the yes button is clicked
private void btnExit_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(“Are you sure you want to exit?”, “Confirmation”, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(result == DialogResult.Yes)
{
this.Close();
}
}
//A method that return the add-0ns item price when both checkboxes are checked, return zero if non are checked
private double getAddOnPrice(CheckBox checkbox1, CheckBox checkBox2, double price)
{
if (checkbox1.Checked && checkBox2.Checked == false)
{
return 0;
}
if (checkbox1.Checked && checkBox2.Checked)
{
return price;
}
return 0;
}
//A method that get the main course item price, return zero when non is clicked
private double getMainCoursePrice(CheckBox checkBox, double price)
{
if (checkBox.Checked == false)
{
return 0;
}
if (checkBox.Checked)
{

return price;
}
return 0;

}
//A method that unchecks the mainCourse of the menu
private void unCheckMainCourse(bool a = false, bool b = false, bool c = false)
{
chkHamburger.Checked = a;
chkPizza.Checked = b;
}
//A method that unchecks the checkbox of the add on items
private void unCheckCheckBox(bool a = false, bool b = false, bool c = false)

{

}

//An Event handler that calculates the subtotal, tax and order total when clicked. Returns zeor if non of the checkboxs are clicked
private void placeOrder_Click(object sender, EventArgs e)
{
clear();
//Calculating of the total order when the placeOder button is clicked
//If the user didn’t select any main course, prompt the user to make a selection
if (totalOrder == 0)
{
DialogResult result = MessageBox.Show(“Please make a valid Main Course selection”, “Error Selection”, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
clear();
}
}
else if (totalOrder > 0)
{
//Setting of the various calculated amount in the listOrderSummary listbox
//Calculating the total tax by using the getTax method
lblTax.Text = getTax(totalOrder, 0.0770).ToString(“c2”);
//Setting the subtal total in the sub total label
lblSubTotal.Text = (totalOrder.ToString(“c2”));
//Calculating and setting the order total amount in the order total label
lblOrderTotal.Text = (totalOrder + getTax(totalOrder, 0.0770)).ToString(“c2″);
//Adding the various calculated amount to the lisb-box
lboxOrderSummary.Items.Add(lblSubTo.Text + ” ” + lblSubTotal.Text);
lboxOrderSummary.Items.Add(lbltX.Text + ” ” + lblTax.Text);
lboxOrderSummary.Items.Add(lblOrToal.Text + ” ” + lblOrderTotal.Text);
}

}

}
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Lunch_Order
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmLunchOrderForm());
}
}
}

Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.