Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button_Calculate_Click(object sender, EventArgs e)
- {
- double UserInput;
- double price;
- double discount;
- if(double.TryParse(textBox_Input.Text, out UserInput))
- {
- if (UserInput > -1 && UserInput < 10)
- {
- //discount 0%
- discount = 99 * 0.0;
- price = 99 - discount;
- label_Discount_Output.Text = discount.ToString();
- label_Output_Price.Text = price.ToString();
- }
- if (UserInput > 9 && UserInput < 20)
- {
- //discount 20%
- discount = 99 *0.2;
- price = 99 - discount;
- label_Discount_Output.Text = discount.ToString();
- label_Output_Price.Text = price.ToString();
- }
- else if (UserInput > 19 && UserInput < 50)
- {
- //discount 30%
- discount = 99 * 0.3;
- price = 99 - discount;
- label_Discount_Output.Text = discount.ToString();
- label_Output_Price.Text = price.ToString();
- }
- else if (UserInput > 49 && UserInput < 99)
- {
- //discount 40%
- discount = 99 * 0.4;
- price = 99 - discount;
- label_Discount_Output.Text = discount.ToString();
- label_Output_Price.Text = price.ToString();
- }
- else if (UserInput > 99)
- {
- //discount 50%
- discount = 99 * 0.5;
- price = 99 - discount;
- label_Discount_Output.Text = discount.ToString();
- label_Output_Price.Text = price.ToString();
- }
- }
- else
- {
- MessageBox.Show("Please input a numerical amount");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement