Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1.         private void button_Calculate_Click(object sender, EventArgs e)
  2.         {
  3.             double UserInput;
  4.             double price;
  5.             double discount;
  6.             if(double.TryParse(textBox_Input.Text, out UserInput))
  7.             {
  8.                 if (UserInput > -1 && UserInput < 10)
  9.                 {
  10.                     //discount 0%
  11.                     discount = 99 * 0.0;
  12.                     price = 99 - discount;
  13.                     label_Discount_Output.Text = discount.ToString();
  14.                     label_Output_Price.Text = price.ToString();
  15.                 }
  16.  
  17.                 if (UserInput > 9 && UserInput < 20)
  18.                 {
  19.                     //discount 20%
  20.                     discount = 99 *0.2;
  21.                     price = 99 - discount;
  22.                     label_Discount_Output.Text = discount.ToString();
  23.                     label_Output_Price.Text = price.ToString();
  24.                 }
  25.  
  26.                 else if (UserInput > 19 && UserInput < 50)
  27.                 {
  28.                     //discount 30%
  29.                     discount = 99 * 0.3;
  30.                     price = 99 - discount;
  31.                     label_Discount_Output.Text = discount.ToString();
  32.                     label_Output_Price.Text = price.ToString();
  33.                 }
  34.  
  35.                 else if (UserInput > 49 && UserInput < 99)
  36.                 {
  37.                     //discount 40%
  38.                     discount = 99 * 0.4;
  39.                     price = 99 - discount;
  40.                     label_Discount_Output.Text = discount.ToString();
  41.                     label_Output_Price.Text = price.ToString();
  42.                 }
  43.  
  44.                 else if (UserInput > 99)
  45.                 {
  46.                     //discount 50%
  47.                     discount = 99 * 0.5;
  48.                     price = 99 - discount;
  49.                     label_Discount_Output.Text = discount.ToString();
  50.                     label_Output_Price.Text = price.ToString();
  51.                 }
  52.  
  53.  
  54.             }
  55.  
  56.             else
  57.             {
  58.                 MessageBox.Show("Please input a numerical amount");
  59.             }
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement