Wednesday, April 23, 2014
CheckBox Exercise
namespace Zau_CheckBox_Exercise
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnGetUserSelection_Click(object sender, EventArgs e)
{
string hobbies = String.Empty;
if (chkSwimming.Checked)
{
hobbies += "Swimming \n";
}
if (chkSkiing.Checked)
{
hobbies += "Skiing \n";
}
if (chkBasketBall.Checked)
{
hobbies += "Basket Ball \n";
}
if (chkGaming.Checked)
{
hobbies += "Gaming \n";
}
if (chkRunning.Checked)
{
hobbies += "Running \n";
}
txtDisplay.Text = hobbies;
}
private void btnClear_Click(object sender, EventArgs e)
{
txtDisplay.Clear();
txtTotal.Clear();
}
private void btnComputeTotal_Click(object sender, EventArgs e)
{
double cost = 0;
string orders = String.Empty;
if(chkSupreme.Checked)
{
orders += "Supreme $15.99 \n";
cost += 15.99;
}
if(chkCheese.Checked)
{
orders += "Cheese $14.99 \n";
cost += 14.99;
}
if(chkPeperino.Checked)
{
orders += "Peperino $13.99 \n";
cost += 13.99;
}
if(chkVegie.Checked)
{
orders += "Vegie $12.99 \n";
cost += 12.99;
}
if(chkSausage.Checked)
{
orders += "Sausage $9.99 \n";
cost += 9.99;
}
double tax = cost * 0.098;
double totalcost = cost + tax;
txtTotal.Text = ("Order\n")+ orders + String.Format
("-----------\nSubTotal: {0:c} \nTax: {1:c} \nTotal Cost: {2:c} \n---------",
cost, tax, totalcost);
}
}
}
Labels:
Week(9-10)
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment