Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. /* Program: Project
  2. Description: Project
  3. Date:9/11/14
  4. Name: Alexandros Bozides 9291
  5. /* Declare libraries used here */
  6. #include <iostream> // Input/Output library
  7. #include <cstdlib>
  8. using namespace std;
  9. //---------------------------------------------------------------------
  10. // Main function - Program begins here
  11. int main()
  12. {
  13. //Variable Declaration for input
  14. int veh_type,cov_level,age,num_acc,num_vio;
  15. bool abs, gdd ;
  16. char abs_ans;
  17. //Variable Declaration for calculation and output
  18. int const vio_fee = 75;
  19. int const acc_fee = 150;
  20. int veh_fee,abs_disc,gdd_disc;
  21. double cov_level_rate,age_rate,premium;
  22.  
  23. //start values
  24. abs = false;
  25. gdd = false;
  26.  
  27. //Input
  28. cout << "Premium Auto Insurance Rates"<< endl;
  29. cout << "====================================="<<endl;
  30. cout << "Vehicle types"<<endl;
  31. cout << "-------------"<<endl;
  32. cout << "1. Sports car"<<endl;
  33. cout << "2. Sedan (4-door)"<<endl;
  34. cout << "3. Sport-Utility/Minivan"<<endl;
  35. cout << "4. Pickup"<<endl;
  36. cout << "5. Motorcycle"<<endl;
  37. cout << " Please input the vehicle type: ";
  38. cin >> veh_type;
  39. cout <<endl;
  40.  
  41. //vehicle type and abs system
  42. if ((veh_type>5)||(veh_type < 0))
  43. {
  44. cout << "invalid number,program will now exit"<<endl;
  45. exit(1); // Returns 1 to the operating system
  46. }
  47.  
  48. if (veh_type !=5)
  49. {
  50. cout << "Does vehicle have antilock braking system (ABS)? (Y/N):";
  51. cin >> abs_ans;
  52. if ((abs_ans == 'Y')||(abs_ans == 'y'))
  53. {
  54. abs = true;
  55. cout << " A discount has been given for ABS " ;
  56. }
  57. else
  58.  
  59. abs = false;
  60.  
  61. }
  62.  
  63. cout <<endl;
  64. //coverage level
  65. cout << "Levels of coverage" << endl<<"-----------------" << endl;
  66. cout << " 1. EUR 15,000/30,000 included " << endl;
  67. cout << " 2. EUR 30,000/60,000 included" << endl;
  68. cout << " 3. EUR 60,000/180,000 " << endl;
  69.  
  70. cout << "Please select a coverage level: ";
  71. cin >> cov_level;
  72.  
  73. if ((cov_level <1)||(cov_level>3))
  74. {
  75. cout << "invalid number,program will now exit"<<endl;
  76. exit(1); // Returns 1 to the operating system
  77. }
  78. cout <<endl;
  79. //age
  80. cout << " Please enter your age: " ;
  81. cin >> age;
  82.  
  83. if (age > 120)
  84. {
  85. cout << "company does not believe people that old should be driving,program will now exit.";
  86. exit(1); // Returns 1 to the operating system
  87. }
  88.  
  89. if (age < 18 )
  90. {
  91. cout << "the client is too young to drive,program will now exit ";
  92. exit(1); // Returns 1 to the operating system
  93. }
  94. cout <<endl;
  95. // accidents and violations
  96. cout << "How many accidents in the last 3 years? ";
  97. cin >> num_acc;
  98.  
  99. cout << " How many traffic violations in the last 3 years? ";
  100. cin >> num_vio;
  101.  
  102. if ((num_acc<0)||(num_vio<0))
  103. {
  104. cout << "User is not giving an honest answer,program will now exit";
  105. exit(1); // Returns 1 to the operating system
  106. }
  107.  
  108. else if ((num_acc>5)||(num_vio>10))
  109. {
  110. cout << "Premio does not insure unsafe drivers,program will now exit";
  111. exit(1); // Returns 1 to the operating system
  112. }
  113.  
  114. else if ((age >= 21)&&((num_acc==0)||(num_vio==0)))
  115. gdd = true;
  116. cout << " A discount has been given for being a Good Driver" << endl;
  117. //calculation
  118.  
  119.  
  120. //vehicle fee
  121. if (veh_type==1)
  122. veh_fee = 500;
  123. else if (veh_type==2)
  124. veh_fee = 350;
  125. else if (veh_type==3)
  126. veh_fee = 400;
  127. else if (veh_type==4)
  128. veh_fee = 375;
  129. else
  130. veh_fee = 300;
  131.  
  132.  
  133. //coverage level fee
  134. if (cov_level == 1)
  135. cov_level_rate = 0.8;
  136. else if (cov_level == 2)
  137. cov_level_rate = 1;
  138. else
  139. cov_level_rate = 1.25;
  140.  
  141. // age rate
  142. if (age < 21)
  143. age_rate = 2;
  144. else if (age < 25)
  145. age_rate = 1.5;
  146. else if ( age <= 65 )
  147. age_rate = 1;
  148. else
  149. age_rate = 1.1;
  150.  
  151.  
  152. //final calculation
  153. if (abs == true)
  154. abs_disc = 50;
  155. else
  156. abs_disc = 0;
  157.  
  158. if (gdd ==true)
  159. gdd_disc = 100;
  160. else
  161. gdd_disc= 0;
  162.  
  163.  
  164. premium = (veh_fee - abs_disc) * cov_level_rate * age_rate + num_acc*acc_fee + num_vio*vio_fee-gdd_disc;
  165. cout <<endl;
  166. //output
  167. cout << " Your rate is the low, low six-month fee of EURO " << premium <<endl;
  168. cout << " Sign up now and we'll throw in a free auto air freshener!";
  169.  
  170. cout <<endl;
  171.  
  172. system("pause");
  173. return 0;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement