Advertisement
Guest User

Untitled

a guest
Jan 24th, 2021
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1._Computer_Store
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string client = Console.ReadLine();
  10.  
  11. double priceWithoutTax = 0;
  12. double tax = 0;
  13. double sumTax = 0;
  14. double totalPrice = 0;
  15.  
  16. while (client != "regular" && client != "special")
  17. {
  18. double price = double.Parse(client);
  19. if (price < 0)
  20. {
  21. Console.WriteLine("Invalid price!");
  22. client = Console.ReadLine();
  23.  
  24. }
  25.  
  26. else
  27. {
  28. priceWithoutTax = priceWithoutTax + price;
  29. tax = 0.2 * price;
  30. sumTax = sumTax + tax;
  31. totalPrice = totalPrice + (price * 1.2);
  32.  
  33. client = Console.ReadLine();
  34. }
  35. }
  36.  
  37. if (totalPrice == 0)
  38. {
  39. Console.WriteLine("Invalid order!");
  40.  
  41. }
  42.  
  43. else if (client == "special")
  44. {
  45. totalPrice = totalPrice * (0.9);
  46. Console.WriteLine("Congratulations you've just bought a new computer!");
  47. Console.WriteLine($"Price without taxes: {priceWithoutTax}$");
  48. Console.WriteLine($"Taxes: {sumTax:F2}$");
  49. Console.WriteLine("-----------");
  50. Console.WriteLine($"Total price: {totalPrice:F2}$");
  51. }
  52.  
  53. else if (client == "regular")
  54. {
  55. Console.WriteLine("Congratulations you've just bought a new computer!");
  56. Console.WriteLine($"Price without taxes: {priceWithoutTax}$");
  57. Console.WriteLine($"Taxes: {sumTax:F2}$");
  58. Console.WriteLine("-----------");
  59. Console.WriteLine($"Total price: {totalPrice:F2}$");
  60.  
  61. }
  62. }
  63. }
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement