Advertisement
Guest User

Untitled

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