MCC - Marquez - CIS162AD
CS5 Pay Calculator with Decisions - 20 points
   cs.gif

In this assignment, the previously completed project (CS4 Pay Calculator) will be enhanced to use If statements to valid the data entered, calculate overtime, and to determine the union dues based on the employee's membership. Radio Buttons will be used to allow the user to select their memberhship type. In addition, images will be added using Picture Boxes to enhance the appearance of the form :-).

Sample Form:

Sample Output (cs5_interface.jpg)

Requirements:

Pseudocode for calculate button:
//CS5 by Your Name - CIS162AD
/*
  	Enter program description here
*/

namespace CS5
{
  public partial class frmCS5 : Form
  (
     public frmCS5()
     {
        InitializeComponent();
     }
	 
     //Declare class level variables (employee count and total netpay) 
     //Declare class level constants (see list above) 
     
     private void btnCalculate_Click(object sender, EventArgs e) 
     { 
         // declare method variables 
         
         //Use nested try-catch blocks to get the input values 
         //so we know which one caused the error 
         try 
         { 
             //Get hours worked from textbox 
             try 
             { 
                 //Get pay rate from textbox 

                 //if statement to validate hours
                     //if statement to validate pay rate                
                     {
                          //We have valid Hours and PayRate - continue processing.
                          //if statement to determine if overtime rate should be applied for gross
                          //if statement to set Union Dues variable - check radio buttons
                          //Calculate taxes
                          //Calculate netpay by subtracting tax and union due amounts from gross
                          //Accumulate summary totals
                          //Calculate Average NetPay
                          //Display the values in labels
                          //Set focus on hours so user is ready to enter next employee
                       }
                       else
                       {
                            MessageBox.Show("Pay Rate must be between $10.00 and $15.00. ", 
                                "Data Entry Error", MessageBoxButtons.OK, 
                                MessageBoxIcon.Exclamation);
                            txtRate.SelectAll();
                            txtRate.Focus();
                       }
                   else
                   {
                        MessageBox.Show("Hours must be between 1 and 50. ",
                            "Data Entry Error", MessageBoxButtons.OK, 
                            MessageBoxIcon.Exclamation);
                        txtHours.SelectAll();
                        txtHours.Focus();
                   }
             }
             //Handle exception for Payrate
             catch (FormatException err) 
             { 
                  MessageBox.Show("Pay Rate must be numeric. " + err.Message, 
                    "Data Entry Error", MessageBoxButtons.OK, 
                    MessageBoxIcon.Exclamation); 
                  txtRate.SelectAll(); 
                  txtRate.Focus(); 
             }
         }
         //Handle exception for Hours
         catch (FormatException err) 
         {  
             MessageBox.Show("Hours worked must be numeric. " + err.Message, 
               "Data Entry Error", MessageBoxButtons.OK, 
               MessageBoxIcon.Exclamation); 
             txtHours.SelectAll(); 
             txtHours.Focus();
         }
         //Handle all other exceptions
         catch (Exception err) 
         {
             MessageBox.Show("Unexpected Error: " + err.Message);
         }
     }//end of btnCalculate

     
     private void btnClearForm_Click(object sender, EventArgs e)
     {
         //Use Clear or null string "" for TextBoxes, but
         //only use null string "" for Labels

         //Set radNone.Checked = true;
         //Reset Accumulators
 
     }//end of btnClearForm


     private void btnExit_Click(object sender, EventArgs e)
     {
         this.Close();
     }


  }//end of class
}//end of namespace

Submit CS5Form.cs and CS5Form.Designer.cs


Revised: 09/27/2011 - www.mesacc.edu/~marquez/cis162ad/cs5_decisions.html