Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DiscountApp
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Please enter the quanitity of the product bought.");
- var x = Console.ReadLine();
- int x1 = int.Parse(x);
- Console.WriteLine("Please enter the price of the product bought.");
- var y = Console.ReadLine();
- double y1 = double.Parse(y);
- double discount = 0;
- double outValue = 0;
- if (x1 <= 100)
- {
- discount = 0.1;
- outValue = returnTotal(discount, y1, x1);
- Console.WriteLine("The total with the discount is R{0}",outValue);
- }
- else if (x1 > 100 && x1 <= 200)
- {
- discount = 0.12;
- outValue = returnTotal(discount, y1, x1);
- Console.WriteLine("The total with the discount is R{0}",outValue);
- }
- else if (x1 > 200 && x1 <= 500)
- {
- discount = 0.15;
- outValue = returnTotal(discount, y1, x1);
- Console.WriteLine("The total with the discount is R{0}",outValue);
- }
- else
- {
- discount = 0.2;
- outValue = returnTotal(discount, y1, x1);
- Console.WriteLine("The total with the discount is R{0}",outValue);
- }
- }
- public static double returnTotal(double discount, double price, int quantity)
- {
- double Total = (price * quantity);
- double discountTotal = Total - (Total * discount);
- return discountTotal;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement