Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Page_Load( object sender, EventArgs e )
- {
- }
- protected void groundRadioButton_CheckedChanged( object sender, EventArgs e )
- {
- performCalculation();
- }
- protected void airMailRadioButton_CheckedChanged( object sender, EventArgs e )
- {
- performCalculation();
- }
- protected void nextDayRadioButton_CheckedChanged( object sender, EventArgs e )
- {
- performCalculation();
- }
- private void performCalculation()
- {
- //Are there values put in the textboxes?
- if (widthTextBox.Text.Trim().Length == 0 && heightTextBox.Text.Trim().Length == 0) return;
- //Is a shipping method selected?
- if (!groundRadioButton.Checked && !airMailRadioButton.Checked && !nextDayRadioButton.Checked) return;
- //get the values out of the 2 text boxes
- int width = int.Parse(widthTextBox.Text);
- int height = int.Parse(heightTextBox.Text);
- //get the volume of package
- double volume = width * height;
- double totalCost = doingMath(volume);
- printResults(totalCost);
- }
- private double doingMath( double volume )
- {
- //figure out the total cost of shipping by using the shipping multiplier provided by Bob
- double totalCost = 0.0;
- if (groundRadioButton.Checked) totalCost = volume * .15;
- else if (airMailRadioButton.Checked) totalCost = volume * .25;
- else if (nextDayRadioButton.Checked) totalCost = volume * .45;
- else totalCost = 0.0;
- return totalCost;
- }
- private void printResults( double totalCost )
- {
- //print out the final result
- resultLabel.Text = String.Format("The Total Cost is: {0:C}", totalCost);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement