Advertisement
NAK

PostalCost

NAK
Apr 30th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             double PostalCost;
  4.             PostalCost = CalculateCost(Convert.ToInt32(textBox1.Text));
  5.             if (PostalCost > 0)
  6.                 textBox2.Text = PostalCost.ToString();
  7.             else
  8.                 textBox2.Text = "To heavy";
  9.         }
  10.  
  11.         private double CalculateCost(int Weight)
  12.         {
  13.  
  14.             if (Weight > 0 && Weight <= 8)
  15.                 return 0.32;
  16.             else if (Weight > 8 && Weight <= 12)
  17.                 return 0.47;
  18.             else if (Weight > 12 && Weight <= 16)
  19.                 return 0.62;
  20.             else if (Weight > 16 && Weight <= 20)
  21.                 return 0.77;
  22.             else if (Weight > 20 && Weight <= 24)
  23.                 return 0.92;
  24.  
  25.         return 0.0;
  26.  
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement