Advertisement
Guest User

Untitled

a guest
May 9th, 2022
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace PhoneBill
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //A phone bill plan includes 1 hour of free calls and 20 text messages for 12.00 levas.
  10. //Each additional minute costs 0.10 levas and each additional message costs 0.06 levas.
  11. //Also, any additional minutes/text messages are subject to 20% sales tax.
  12. //Write a program that calculates the additional charge for text, the additional charge for minutes, and the sales tax charge
  13. //for both.
  14. //Also, display the total amount paid.
  15.  
  16. int totalMessages = int.Parse(Console.ReadLine());
  17. int totalMinutes = int.Parse(Console.ReadLine());
  18.  
  19. int additionalMessages = 0;
  20. int additionalMinutes = 0;
  21. double valueOfMessages = 0;
  22. double valueOfMinutes = 0;
  23. double taxValue = 0;
  24. int fee = 12;
  25.  
  26. // add cases when minutes are more and case for when messages only are more
  27. if (totalMessages > 20 && totalMinutes>60)
  28. {
  29. additionalMessages = totalMessages - 20;
  30. valueOfMessages = additionalMessages * 0.06;
  31. additionalMinutes = totalMinutes - 60;
  32. valueOfMinutes = additionalMinutes * 0.10;
  33.  
  34. Console.WriteLine($"{additionalMessages} additional messages for {valueOfMessages:F2} levas");
  35. Console.WriteLine($"{additionalMinutes} additional minutes for {valueOfMinutes:F2} levas");
  36. taxValue = (valueOfMinutes + valueOfMessages) * 0.20;
  37. Console.WriteLine($"{taxValue:F2} additional taxes");
  38. Console.WriteLine($"{valueOfMinutes+valueOfMessages+taxValue+fee:F2} total bill");
  39.  
  40. }else if (totalMessages<=20 && totalMinutes<=60)
  41. {
  42. Console.WriteLine($"{0} additional messages for {0.00:F2} levas");
  43. Console.WriteLine($"{0} additional minutes for {0.00:F2} levas");
  44. Console.WriteLine($"{0.00:F2} additional taxes");
  45. Console.WriteLine($"{fee} total bill");
  46. }else if (totalMessages>20 && totalMinutes <= 60)
  47. {
  48. additionalMessages = totalMessages - 20;
  49. valueOfMessages = additionalMessages * 0.06;
  50.  
  51. Console.WriteLine($"{additionalMessages} additional messages for {valueOfMessages:F2} levas");
  52. Console.WriteLine($"{0} additional minutes for {0.00:F2} levas");
  53. taxValue = valueOfMessages * 0.20;
  54. Console.WriteLine($"{taxValue:F2} additional taxes");
  55. Console.WriteLine($"{valueOfMessages + taxValue + fee:F2} total bill");
  56. }else if (totalMessages<=20 && totalMinutes > 60)
  57. {
  58.  
  59. additionalMinutes = totalMinutes - 60;
  60. valueOfMinutes = additionalMinutes * 0.10;
  61.  
  62. Console.WriteLine($"{0} additional messages for {0.00:F2} levas");
  63. Console.WriteLine($"{additionalMinutes} additional minutes for {valueOfMinutes:F2} levas");
  64. taxValue = valueOfMinutes * 0.20;
  65. Console.WriteLine($"{taxValue:F2} additional taxes");
  66. Console.WriteLine($"{valueOfMinutes + taxValue + fee:F2} total bill");
  67. }
  68.  
  69. //Output
  70. //11 additional messages for 0.66 levas
  71. //55 additional minutes for 5.50 levas
  72. //1.23 additional taxes
  73. //19.39 total bill
  74.  
  75.  
  76.  
  77. }
  78. }
  79. }
  80.  
Advertisement
RAW Paste Data Copied
Advertisement