Invoice Total

               Note: AcceptButton property of form set to "btnCalculate" - when "ENTER" pressed, click event executes.
                     CancelButton property of form set to "btnExit" - when "ESC" pressed, click event executes.
               Note: Shortcut keys are set for both buttons ('&' simply inserted in Text property) 
                     and are accessed as "alt-key" (alt-C and alt-X for this example).

// Code from text with slight mods (Wyatt)
// Terry T Trainer CIS 202 3/22/2013
   get amount from user
   calculate discount amount 
   calculate total 
using System;
using System.Windows.Forms;

namespace InvoiceTotal
   public partial class frmInvoiceTotal : Form
      // Creates the GUI - this code is generated AUTOMATICALLY by the system
      public frmInvoiceTotal()

      // calculates the discount and the invoice total
      private void btnCalculate_Click(object sender, EventArgs e)
         // declare variables to store data and information                 
         const double discountPercent = .25; // 25 percent       
         double discountAmount, invoiceTotal, subtotal; // allows fractional numbers
         // read the subtotal from text box and convert string to a number
         subtotal = double.Parse(txtSubtotal.Text);

         // calculate the discount and total
         discountAmount = subtotal * discountPercent;
         invoiceTotal = subtotal - discountAmount;

         // output the information to the textbox on the form
         txtDiscountPercent.Text = discountPercent.ToString("p1"); // 'p' means as a percent
         txtDiscountAmount.Text = discountAmount.ToString("c"); // 'c' means as curerency
         txtTotal.Text = invoiceTotal.ToString("c");

         // put the cursor back at textbox so next amount can easily be entered

      // exits the program
      private void btnExit_Click(object sender, EventArgs e)