Advertisement
andidegn

Untitled

Apr 27th, 2013
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12.  
  13. namespace CSSTEst
  14. {
  15.     public partial class Index : System.Web.UI.Page
  16.     {
  17.         double level = 0;
  18.         int time = 0;
  19.         double distance = 0;
  20.  
  21.         protected void Page_Load(object sender, EventArgs e)
  22.         {
  23.  
  24.         }
  25.  
  26.         protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
  27.  
  28.         }
  29.  
  30.         protected void Button1_Click(object sender, EventArgs e)
  31.         {
  32.             //Label5.Text = int.Parse(TimeHours.Text);
  33.             int hour = (int.Parse(TimeHours.Text));
  34.             int min = (int.Parse(TimeMinutes.Text));
  35.             int time = (hour * 60) + min;
  36.             double result = 0;
  37.             double weight = (double.Parse(TextBox1.Text));
  38.             double distance = (double.Parse(TextBox2.Text));
  39.  
  40.  
  41.             if (DropDownList1.SelectedIndex == 1) {
  42.                 level = 7;
  43.             }
  44.             if (DropDownList1.SelectedIndex == 2) {
  45.                 level = 11;
  46.             }
  47.             if (DropDownList1.SelectedIndex == 3) {
  48.                 level = 10;
  49.             }
  50.             if (DropDownList1.SelectedIndex == 4) {
  51.                 level = ((distance / time) * 0.12) + 2.6;
  52.             } else {
  53.                 Label5.Text = "Please select a style of swimming.";
  54.             }
  55.  
  56.             if (RadioButtonList1.SelectedIndex == 0) {
  57.                 result = 1.05 * level * weight * time;
  58.                 Label5.Text = "You burned: " + result.ToString() + " calories.";
  59.             } else
  60.             if (RadioButtonList1.SelectedIndex == 1) {
  61.                 result = 0.0175 * level * weight * time;
  62.                 Label5.Text = "You burned: " + result.ToString() + " calories.";
  63.             } else {
  64.                 Label5.Text = "Please check your entries.";
  65.             }
  66.         }
  67.         protected void Button2_Click(object sender, EventArgs e)
  68.         {
  69.            Button2.Attributes.Add("onClick", "document.forms[0].reset();return false;");
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement