Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnCalc_Click(object sender, EventArgs e)
- {
- // Take in Data from text box and convert to integer
- int numCopies = Convert.ToInt32(txtCopies.Text);
- // Create two temp variables for math we need to do
- double tempCost;
- double tempCopies;
- if (numCopies <= 100)
- {
- //Calculate the cost if number of copies is less than 100
- tempCost = numCopies * 0.1;
- //Output to text box and multiple by 23% to add vat
- txtIncVat.Text = Convert.ToString(tempCost * 1.23);
- }
- else if (numCopies <= 200)
- {
- //If its greater than 200 we know the first 100 will be charged at 10 cent we need to find how many will be at 6 cent. We must take the 100 from the number of copies to find the number left over. The left over is how many will be charged at 6 cent
- tempCopies = numCopies - 100;
- // We add the first 100 at 10 cent and then we take the remaining copies and charge them at 6 cent.
- tempCost = (100 * 0.1) + tempCopies * 0.06;
- // Output the cost to the text box
- txtIncVat.Text = Convert.ToString(tempCost * 1.23);
- }
- else
- {
- // This time we take 200 because we know the first 100 at 10 cent and the second 100 at 6 cent we need the final remainder.
- tempCopies = numCopies - 200;
- //Then finally add the cost of the first 100 at 10 cent, the second 100 at 6 cent, then we get our remainder and multiply it by 4 cent.
- tempCost = (100 * 0.1) + (100 * 0.06) + tempCopies * 0.04;
- txtIncVat.Text = Convert.ToString(tempCost * 1.23);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement