Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program: Project
- Description: Project
- Date:9/11/14
- Name: Alexandros Bozides 9291
- /* Declare libraries used here */
- #include <iostream> // Input/Output library
- #include <cstdlib>
- using namespace std;
- //---------------------------------------------------------------------
- // Main function - Program begins here
- int main()
- {
- //Variable Declaration for input
- int veh_type,cov_level,age,num_acc,num_vio;
- bool abs, gdd ;
- char abs_ans;
- //Variable Declaration for calculation and output
- int const vio_fee = 75;
- int const acc_fee = 150;
- int veh_fee,abs_disc,gdd_disc;
- double cov_level_rate,age_rate,premium;
- //start values
- abs = false;
- gdd = false;
- //Input
- cout << "Premium Auto Insurance Rates"<< endl;
- cout << "====================================="<<endl;
- cout << "Vehicle types"<<endl;
- cout << "-------------"<<endl;
- cout << "1. Sports car"<<endl;
- cout << "2. Sedan (4-door)"<<endl;
- cout << "3. Sport-Utility/Minivan"<<endl;
- cout << "4. Pickup"<<endl;
- cout << "5. Motorcycle"<<endl;
- cout << " Please input the vehicle type: ";
- cin >> veh_type;
- cout <<endl;
- //vehicle type and abs system
- if ((veh_type>5)||(veh_type < 0))
- {
- cout << "invalid number,program will now exit"<<endl;
- exit(1); // Returns 1 to the operating system
- }
- if (veh_type !=5)
- {
- cout << "Does vehicle have antilock braking system (ABS)? (Y/N):";
- cin >> abs_ans;
- if ((abs_ans == 'Y')||(abs_ans == 'y'))
- {
- abs = true;
- cout << " A discount has been given for ABS " ;
- }
- else
- abs = false;
- }
- cout <<endl;
- //coverage level
- cout << "Levels of coverage" << endl<<"-----------------" << endl;
- cout << " 1. EUR 15,000/30,000 included " << endl;
- cout << " 2. EUR 30,000/60,000 included" << endl;
- cout << " 3. EUR 60,000/180,000 " << endl;
- cout << "Please select a coverage level: ";
- cin >> cov_level;
- if ((cov_level <1)||(cov_level>3))
- {
- cout << "invalid number,program will now exit"<<endl;
- exit(1); // Returns 1 to the operating system
- }
- cout <<endl;
- //age
- cout << " Please enter your age: " ;
- cin >> age;
- if (age > 120)
- {
- cout << "company does not believe people that old should be driving,program will now exit.";
- exit(1); // Returns 1 to the operating system
- }
- if (age < 18 )
- {
- cout << "the client is too young to drive,program will now exit ";
- exit(1); // Returns 1 to the operating system
- }
- cout <<endl;
- // accidents and violations
- cout << "How many accidents in the last 3 years? ";
- cin >> num_acc;
- cout << " How many traffic violations in the last 3 years? ";
- cin >> num_vio;
- if ((num_acc<0)||(num_vio<0))
- {
- cout << "User is not giving an honest answer,program will now exit";
- exit(1); // Returns 1 to the operating system
- }
- else if ((num_acc>5)||(num_vio>10))
- {
- cout << "Premio does not insure unsafe drivers,program will now exit";
- exit(1); // Returns 1 to the operating system
- }
- else if ((age >= 21)&&((num_acc==0)||(num_vio==0)))
- gdd = true;
- cout << " A discount has been given for being a Good Driver" << endl;
- //calculation
- //vehicle fee
- if (veh_type==1)
- veh_fee = 500;
- else if (veh_type==2)
- veh_fee = 350;
- else if (veh_type==3)
- veh_fee = 400;
- else if (veh_type==4)
- veh_fee = 375;
- else
- veh_fee = 300;
- //coverage level fee
- if (cov_level == 1)
- cov_level_rate = 0.8;
- else if (cov_level == 2)
- cov_level_rate = 1;
- else
- cov_level_rate = 1.25;
- // age rate
- if (age < 21)
- age_rate = 2;
- else if (age < 25)
- age_rate = 1.5;
- else if ( age <= 65 )
- age_rate = 1;
- else
- age_rate = 1.1;
- //final calculation
- if (abs == true)
- abs_disc = 50;
- else
- abs_disc = 0;
- if (gdd ==true)
- gdd_disc = 100;
- else
- gdd_disc= 0;
- premium = (veh_fee - abs_disc) * cov_level_rate * age_rate + num_acc*acc_fee + num_vio*vio_fee-gdd_disc;
- cout <<endl;
- //output
- cout << " Your rate is the low, low six-month fee of EURO " << premium <<endl;
- cout << " Sign up now and we'll throw in a free auto air freshener!";
- cout <<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement