SlideShare a Scribd company logo
1 of 2
Page 1
Add to order button
private void addToOrderButton_Click(object sender, EventArgs e) {
// Add the current item price and quantity to the order.
if (noSizeRadioButton.Checked) {
MessageBox.Show("You must select a drink and size.",
"Missing required entry"); }
else {
try {
int quantityInteger = int.Parse(quantityTextBox.Text);
if (quantityInteger > 0) {
drinksInteger += quantityInteger;
totalOrderDecimal += drinkDecimal * quantityInteger;
clearForNextItem();
orderCompleteButton.Enabled = true; }
else {
MessageBox.Show("Please enter a quantity",
"Missing Required Entry"); } }
catch (FormatException) {
MessageBox.Show("Invalid Quantity", "Data Entry Error");
quantityTextBox.Focus();
quantityTextBox.SelectAll(); } } }
Order Complete
private void orderCompletebutton_Click(object sender, EventArgs e)
{
// Order is complete, add to summary and clear order.
// Check if the last item was added to the total.
if (itemPriceTextBox.Text != "")
{
DialogResult responseDialogResult;
string messageString = "Current item not recorded. Add to order?";
responseDialogResult = MessageBox.Show(messageString,
"Verify Last Drink Purchase", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (responseDialogResult == DialogResult.Yes)
{
addToOrderButton_Click(sender, e); } }
Page 2
// Display amount due.
string dueString = "Amount Due " + totalOrderDecimal.ToString("C");
MessageBox.Show(dueString, "Order Complete");
// Add to summary totals.
ordersInteger++;
totalSalesDecimal += totalOrderDecimal;
// Reset all for new order.
summaryButton.Enabled = true;
summaryToolStripMenuItem.Enabled = true;
orderCompleteButton.Enabled = false;
orderCompleteToolStripMenuItem.Enabled = false;
totalOrderDecimal = 0m;
}
Summary Button
private void summaryButton_Click(object sender, EventArgs e)
{
// Display the summary information in a message box.
string summaryString = "Drinks Sold: " + drinksInteger.ToString()
+ "nn" + "Number of Orders: " + ordersInteger.ToString()
+ "nn" + "Total Sales: " + totalSalesDecimal.ToString("C");
MessageBox.Show(summaryString, "Juice Bar Sales Summary",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void exitButton_Click(object sender, EventArgs e)
{
// End the application.
this.Close();
}
Twelve Ounce Radio Button
private void twelveOunceRadioButton_CheckedChanged(object sender, EventArgs e)
{
// Calculate and display the price for the selected item.
// Handles all check boxes and radio buttons.
// Cast the sender to a RadioButton type.
RadioButton selectedSizeRadioButton = (RadioButton)sender;
switch (selectedSizeRadioButton.Name)
Page 3
{
case "twelveOunceRadioButton":
itemSizeDecimal = 3m;
break;
case "sixteenOunceRadioButton":
itemSizeDecimal = 3.5m;
break;
case "twentyOunceRadioButton":
itemSizeDecimal = 4m;
break;
}
drinkDecimal = itemSizeDecimal + findExtrasPrice();
itemPriceTextBox.Text = drinkDecimal.ToString("C");
}
private void clearForNextItem()
{
// Clear radio buttons, check boxes, text boxes.
noSizeRadioButton.Checked = true;
fruitJuiceRadioButton.Checked = true;
vitaminPackCheckBox.Checked = false;
energyBoosterCheckBox.Checked = false;
ladiesCheckBox.Checked = false;
itemPriceTextBox.Clear();
quantityTextBox.Text = "1";
}
private decimal findExtrasPrice()
{
// Find price for additives.
decimal extrasDecimal = 0m;
if (vitaminPackCheckBox.Checked)
extrasDecimal += .5m;
if (energyBoosterCheckBox.Checked)
extrasDecimal += .5m;
if (ladiesCheckBox.Checked)
extrasDecimal += .5m;
return extrasDecimal;
}
private void vitaminPackCheckBox_CheckedChanged(object sender, EventArgs e)
Page 4
{
// Check price of additives and display current price.
// Handles all three check boxes.
drinkDecimal = itemSizeDecimal + findExtrasPrice();
itemPriceTextBox.Text = drinkDecimal.ToString("C");
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
// Display information in a message box.
string aboutString = "Programmed by A. ProgrammernVersion 1.1";
string captionString =
"About Look Sharp Fitness Center Juice Bar Orders";
MessageBox.Show(aboutString, captionString);
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
// Change the label’s font.
// Initialize the dialog box.
fontDialog1.Font = titleLabel.Font;
// Display the dialog box.
fontDialog1.ShowDialog();
// Assign the new font.
titleLabel.Font = fontDialog1.Font;
}
private void colorToolStripMenuItem_Click(object sender, EventArgs e)
{
// Change the form’s ForeColor.
// Applies to all controls on the form that haven’t had their
// ForeColor explicitly modified.
// Initialize the dialog box.
colorDialog1.Color = this.ForeColor;
// Display the dialog box.
colorDialog1.ShowDialog();
// Assign the new color.
this.ForeColor = colorDialog1.Color;
}
}
}

More Related Content

Similar to Codes.docx

I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...hwbloom115
 
Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008atsumagaysay
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaYusman Kurniadi
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfarihantmum
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15Rajes Wari
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide guiMahmoud Hikmet
 
Basic calculator tutorial
Basic calculator tutorialBasic calculator tutorial
Basic calculator tutorialGilkye
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
 
C# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdfC# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdffathimalinks
 
Hello everyone,Im actually working on a fast food order program..pdf
Hello everyone,Im actually working on a fast food order program..pdfHello everyone,Im actually working on a fast food order program..pdf
Hello everyone,Im actually working on a fast food order program..pdffedosys
 
Project: Call Center Management
Project: Call Center ManagementProject: Call Center Management
Project: Call Center Managementpritamkumar
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfShaiAlmog1
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Bhushan Mulmule
 
VisualBasicExample
VisualBasicExampleVisualBasicExample
VisualBasicExampleBo Dake
 
Burger doll order form
Burger doll order formBurger doll order form
Burger doll order formKhairi Aiman
 
Html,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tagsHtml,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tagsJeirahTigas
 

Similar to Codes.docx (20)

I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...
 
Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
 
Ensayo
EnsayoEnsayo
Ensayo
 
Basic calculator tutorial
Basic calculator tutorialBasic calculator tutorial
Basic calculator tutorial
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
C# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdfC# Program. Create a Windows application that has the functionality .pdf
C# Program. Create a Windows application that has the functionality .pdf
 
Hello everyone,Im actually working on a fast food order program..pdf
Hello everyone,Im actually working on a fast food order program..pdfHello everyone,Im actually working on a fast food order program..pdf
Hello everyone,Im actually working on a fast food order program..pdf
 
Project: Call Center Management
Project: Call Center ManagementProject: Call Center Management
Project: Call Center Management
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdf
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
 
VisualBasicExample
VisualBasicExampleVisualBasicExample
VisualBasicExample
 
Burger doll order form
Burger doll order formBurger doll order form
Burger doll order form
 
Html,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tagsHtml,Css and Javascript Forms using different tags
Html,Css and Javascript Forms using different tags
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

Codes.docx

  • 1. Page 1 Add to order button private void addToOrderButton_Click(object sender, EventArgs e) { // Add the current item price and quantity to the order. if (noSizeRadioButton.Checked) { MessageBox.Show("You must select a drink and size.", "Missing required entry"); } else { try { int quantityInteger = int.Parse(quantityTextBox.Text); if (quantityInteger > 0) { drinksInteger += quantityInteger; totalOrderDecimal += drinkDecimal * quantityInteger; clearForNextItem(); orderCompleteButton.Enabled = true; } else { MessageBox.Show("Please enter a quantity", "Missing Required Entry"); } } catch (FormatException) { MessageBox.Show("Invalid Quantity", "Data Entry Error"); quantityTextBox.Focus(); quantityTextBox.SelectAll(); } } } Order Complete private void orderCompletebutton_Click(object sender, EventArgs e) { // Order is complete, add to summary and clear order. // Check if the last item was added to the total. if (itemPriceTextBox.Text != "") { DialogResult responseDialogResult; string messageString = "Current item not recorded. Add to order?"; responseDialogResult = MessageBox.Show(messageString, "Verify Last Drink Purchase", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (responseDialogResult == DialogResult.Yes) { addToOrderButton_Click(sender, e); } } Page 2 // Display amount due. string dueString = "Amount Due " + totalOrderDecimal.ToString("C"); MessageBox.Show(dueString, "Order Complete"); // Add to summary totals. ordersInteger++; totalSalesDecimal += totalOrderDecimal; // Reset all for new order. summaryButton.Enabled = true; summaryToolStripMenuItem.Enabled = true; orderCompleteButton.Enabled = false; orderCompleteToolStripMenuItem.Enabled = false; totalOrderDecimal = 0m; } Summary Button private void summaryButton_Click(object sender, EventArgs e) { // Display the summary information in a message box. string summaryString = "Drinks Sold: " + drinksInteger.ToString() + "nn" + "Number of Orders: " + ordersInteger.ToString() + "nn" + "Total Sales: " + totalSalesDecimal.ToString("C"); MessageBox.Show(summaryString, "Juice Bar Sales Summary", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void exitButton_Click(object sender, EventArgs e) { // End the application. this.Close(); } Twelve Ounce Radio Button private void twelveOunceRadioButton_CheckedChanged(object sender, EventArgs e) { // Calculate and display the price for the selected item. // Handles all check boxes and radio buttons. // Cast the sender to a RadioButton type. RadioButton selectedSizeRadioButton = (RadioButton)sender; switch (selectedSizeRadioButton.Name)
  • 2. Page 3 { case "twelveOunceRadioButton": itemSizeDecimal = 3m; break; case "sixteenOunceRadioButton": itemSizeDecimal = 3.5m; break; case "twentyOunceRadioButton": itemSizeDecimal = 4m; break; } drinkDecimal = itemSizeDecimal + findExtrasPrice(); itemPriceTextBox.Text = drinkDecimal.ToString("C"); } private void clearForNextItem() { // Clear radio buttons, check boxes, text boxes. noSizeRadioButton.Checked = true; fruitJuiceRadioButton.Checked = true; vitaminPackCheckBox.Checked = false; energyBoosterCheckBox.Checked = false; ladiesCheckBox.Checked = false; itemPriceTextBox.Clear(); quantityTextBox.Text = "1"; } private decimal findExtrasPrice() { // Find price for additives. decimal extrasDecimal = 0m; if (vitaminPackCheckBox.Checked) extrasDecimal += .5m; if (energyBoosterCheckBox.Checked) extrasDecimal += .5m; if (ladiesCheckBox.Checked) extrasDecimal += .5m; return extrasDecimal; } private void vitaminPackCheckBox_CheckedChanged(object sender, EventArgs e) Page 4 { // Check price of additives and display current price. // Handles all three check boxes. drinkDecimal = itemSizeDecimal + findExtrasPrice(); itemPriceTextBox.Text = drinkDecimal.ToString("C"); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { // Display information in a message box. string aboutString = "Programmed by A. ProgrammernVersion 1.1"; string captionString = "About Look Sharp Fitness Center Juice Bar Orders"; MessageBox.Show(aboutString, captionString); } private void fontToolStripMenuItem_Click(object sender, EventArgs e) { // Change the label’s font. // Initialize the dialog box. fontDialog1.Font = titleLabel.Font; // Display the dialog box. fontDialog1.ShowDialog(); // Assign the new font. titleLabel.Font = fontDialog1.Font; } private void colorToolStripMenuItem_Click(object sender, EventArgs e) { // Change the form’s ForeColor. // Applies to all controls on the form that haven’t had their // ForeColor explicitly modified. // Initialize the dialog box. colorDialog1.Color = this.ForeColor; // Display the dialog box. colorDialog1.ShowDialog(); // Assign the new color. this.ForeColor = colorDialog1.Color; } } }