Advertisement
oaktree

insurance (programming challenge #2)

May 14th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. int main() {
  6.     std::cout << "Please enter the number of drivers in your family: ";
  7.     int drivers; std::cin >> drivers;
  8.  
  9.     std::string name;
  10.     unsigned int age;
  11.  
  12.     for (int i = 0; i < drivers; i++) {
  13.         std::cout << "Driver " << i+1 << " name: ";
  14.         std::cin >> name;
  15.  
  16.         std::cout << "Driver " << i+1 << " age: ";
  17.         std::cin >> age;
  18.  
  19.         int cost = 1000;
  20.  
  21.         if (age < 16) {
  22.             cost *= 0;
  23.         } else if (age <= 19) {
  24.             cost *= 1.15;
  25.         } else if (age <= 25) {
  26.             cost *= 1.05;
  27.         } else {
  28.             cost *= 0.9;
  29.         }
  30.  
  31.         std::cout << "The cost of insurance for " << name << " is $" << cost \
  32.         << ".\n\n";
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement