Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void widthTextBox_TextChanged(object sender, EventArgs e)
- {
- if (!EntryError()) return;
- }
- double width = 0;
- double length = 0;
- double height = 0;
- private bool EntryError()
- {
- if (!double.TryParse(widthTextBox.Text.Trim(), out width)) return false;
- if (!double.TryParse(heightTextBox.Text.Trim(), out height)) return false;
- if (!double.TryParse(lengthTextBox.Text.Trim(), out length)) length = 1;
- double volume = width * height * length;
- calculateTheCost(volume);
- return true;
- }
- private void calculateTheCost(double volume)
- {
- double postageMultipler = getPostageMultiplier() * volume;
- displayResult(postageMultipler);
- }
- private double getPostageMultiplier()
- {
- if (groundRadioButton.Checked) return .15;
- if (airRadioButton.Checked) return .25;
- if (nextDayRadioButton.Checked) return .45;
- else return 0;
- }
- private void displayResult(double postageMultipler)
- {
- resultLabel.Text = string.Format("Your parcel will cost {0:C} to ship", postageMultipler.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement