Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DiscountApp
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Please enter the quanitity of the product bought.");
  14. var x = Console.ReadLine();
  15. int x1 = int.Parse(x);
  16.  
  17. Console.WriteLine("Please enter the price of the product bought.");
  18. var y = Console.ReadLine();
  19. double y1 = double.Parse(y);
  20.  
  21. double discount = 0;
  22. double outValue = 0;
  23.  
  24. if (x1 <= 100)
  25. {
  26. discount = 0.1;
  27. outValue = returnTotal(discount, y1, x1);
  28. Console.WriteLine("The total with the discount is R{0}",outValue);
  29. }
  30. else if (x1 > 100 && x1 <= 200)
  31. {
  32. discount = 0.12;
  33. outValue = returnTotal(discount, y1, x1);
  34. Console.WriteLine("The total with the discount is R{0}",outValue);
  35. }
  36. else if (x1 > 200 && x1 <= 500)
  37. {
  38. discount = 0.15;
  39. outValue = returnTotal(discount, y1, x1);
  40. Console.WriteLine("The total with the discount is R{0}",outValue);
  41. }
  42. else
  43. {
  44. discount = 0.2;
  45. outValue = returnTotal(discount, y1, x1);
  46. Console.WriteLine("The total with the discount is R{0}",outValue);
  47. }
  48.  
  49.  
  50. }
  51. public static double returnTotal(double discount, double price, int quantity)
  52. {
  53. double Total = (price * quantity);
  54. double discountTotal = Total - (Total * discount);
  55. return discountTotal;
  56. }
  57.  
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement