Advertisement
andidegn

Untitled

Apr 27th, 2013
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2.         {
  3.             //Label5.Text = int.Parse(TimeHours.Text);
  4.             try {
  5.                 int hour = (int.Parse(TimeHours.Text));
  6.                 int min = (int.Parse(TimeMinutes.Text));
  7.                 int time = (hour * 60) + min;
  8.                 double result = 0;
  9.                 double weight = (double.Parse(TextBox1.Text));
  10.                 double distance = (double.Parse(TextBox2.Text));
  11.                 if (DropDownList1.SelectedIndex == 1) {
  12.                     level = 7;
  13.                 }
  14.                 if (DropDownList1.SelectedIndex == 2) {
  15.                     level = 11;
  16.                 }
  17.                 if (DropDownList1.SelectedIndex == 3) {
  18.                     level = 10;
  19.                 }
  20.                 if (DropDownList1.SelectedIndex == 4) {
  21.                     level = ((distance / time) * 0.12) + 2.6;
  22.                 } else {
  23.                     Label5.Text = "Please select a style of swimming.";
  24.                 }
  25.  
  26.                 if (RadioButtonList1.SelectedIndex == 0) {
  27.                     result = 1.05 * level * weight * time;
  28.                     Label5.Text = "You burned: " + result.ToString() + " calories.";
  29.                 } else
  30.                 if (RadioButtonList1.SelectedIndex == 1) {
  31.                     result = 0.0175 * level * weight * time;
  32.                     Label5.Text = "You burned: " + result.ToString() + " calories.";
  33.                 } else {
  34.                     Label5.Text = "Please check your entries.";
  35.                 }
  36.             } catch (FormatException) {
  37.                 Label5.Text = "Please check your entries.";
  38.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement