Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include<stdlib.h>
  4. #include<stdio.h>
  5. char line_text[50];
  6. float carprice, downpayment, interest, noofyears;
  7. float installment;
  8. int cc;
  9. float rtax;
  10. void hirepurchase ()
  11. {
  12. printf("Input Car Price");
  13. fgets(line_text, sizeof(line_text), stdin);
  14. sscanf(line_text, "%f", &carprice);
  15.  
  16. printf("Input Downpayment");
  17. fgets(line_text, sizeof(line_text), stdin);
  18. sscanf(line_text, "%f", &downpayment);
  19.  
  20. printf("Input Interest Rate");
  21. fgets(line_text, sizeof(line_text), stdin);
  22. sscanf(line_text, "%f", &interest);
  23.  
  24. printf("Input No Of Years");
  25. fgets(line_text, sizeof(line_text), stdin);
  26. sscanf(line_text, "%f", &noofyears);
  27.  
  28. installment = (((((carprice - downpayment)*interest) / 100)*(noofyears)) + (carprice - downpayment)) / (noofyears * 12);
  29.  
  30. printf("\nYour Monthly Installment is : %.2f\n", installment);
  31. system("pause");
  32. system("cis");
  33. }
  34.  
  35. void roadtax ()
  36. {
  37. printf("Input Your Engine CC [example : 1500,1600,2000]");
  38. fgets(line_text, sizeof(line_text), stdin);
  39. sscanf(line_text, "%i", &cc);
  40. if (cc > 0 && cc < 1001)
  41. {
  42. rtax = 20;
  43. }
  44. else if (cc > 1000 && cc < 1201)
  45. {
  46. rtax = 110;
  47. }
  48. else if (cc > 1200 && cc < 1401)
  49. {
  50. rtax = 140;
  51. }
  52. else if (cc > 1400 && cc < 1601)
  53. {
  54. rtax = 180;
  55. }
  56. else if (cc > 1600 && cc < 1801)
  57. {
  58. rtax = (1800 - cc)*0.8 + 400;
  59. }
  60. else if (cc > 1800 && cc < 2001)
  61. {
  62. rtax = (2000 - cc)*1.0 + 560;
  63. }
  64. else if (cc > 2000 && cc < 2501)
  65. {
  66. rtax = (2500 - cc)*3.0 + 760;
  67. }
  68. else if (cc > 2500 && cc < 3001)
  69. {
  70. rtax = (3000 - cc)*7.5 + 2260;
  71. }
  72. else if (cc > 3001)
  73. {
  74. rtax = (cc-3000)*13.5 + 6010;
  75. }
  76. else
  77. {
  78. printf("oops, thing went wrong !");
  79. rtax = 0.0;
  80. }
  81. printf("\nYour payable amount for road tax is : %.2f\n", rtax);
  82. system("pause");
  83. system("cis");
  84.  
  85.  
  86.  
  87.  
  88. }
  89. void main()
  90. {
  91. int choice = 0;
  92. do
  93. {
  94. printf("1.Hire Purchase Calculator\n");
  95. printf("2.RoadTax Calculator\n");
  96. printf("Enter 1 or 2 or anything to exit\n");
  97. fgets(line_text, sizeof(line_text), stdin);
  98. sscanf(line_text, "%i", &choice);
  99.  
  100. if (choice == 1)
  101. {
  102. hirepurchase ();
  103. }
  104. else if (choice == 2)
  105. {
  106. roadtax ();
  107. }
  108. else
  109. {
  110. printf("Invalid Choice !!");
  111. system ("pause");
  112. }
  113. } while (choice == 1|| choice == 2 );
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement