Advertisement
Guest User

pron_noodz

a guest
Jan 24th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    
  8.     int adoption_process, adoption_amt, animal_amt, animal_choice, total_fee;
  9.     int adoption_budget, amount_spent;
  10.     cout << "Please select an adoption process:" << endl;
  11.     cout << "1) Adoption by animal amount" << endl;
  12.     cout << "2) Adoption by budget" << endl;
  13.    
  14.     cin >> adoption_process;
  15.     /* adoption by animal amount */
  16.     if (adoption_process == 1) {
  17.         cout << "Enter the amount of animals you are adopting: " << endl;
  18.         cin >> adoption_amt;
  19.         for (animal_amt=0; animal_amt < adoption_amt; animal_amt += 1){
  20.  
  21.             cout << "Which dog would you like to adopt?" << endl;
  22.             cout << "1) Small dog ($25)" << endl;
  23.             cout << "2) Medium dog ($40)" << endl;
  24.             cout << "3) Large dog ($65)" << endl;
  25.  
  26.             cin >> animal_choice;
  27.  
  28.             switch(animal_choice){
  29.  
  30.                 case 1:
  31.                     cout << "You have chosen a small dog for $25!" << endl;
  32.                     total_fee += 25;
  33.                     break;
  34.                 case 2:
  35.                     cout << "You have chosen a medium dog for $40!" << endl;
  36.                     total_fee += 40;
  37.                     break;
  38.                 case 3:
  39.                     cout << "You have chosen a large dog for $65!" << endl;
  40.                     total_fee += 65;
  41.                     break;
  42.  
  43.             }
  44.         }
  45.         cout << "Your final total is $" << total_fee << " for " << animal_amt << " dog(s).";
  46.     }
  47.     /* adoption by budget */
  48.     else {
  49.         cout << "Enter your adoption budget: $" << endl;
  50.         cin >> adoption_budget;
  51.         int pet_prices [3] = {25, 40, 65};
  52.         animal_amt = 0;
  53.         bool exit = false;
  54.  
  55.         do {
  56.             cout << "Which dog would you like to adopt?" << endl;
  57.             cout << "1) Small dog ($25)" <<endl;
  58.             cout << "2) Medium dog ($40)" << endl;
  59.             cout << "3) Large dog ($65)" << endl;
  60.             cout << "4) Exit" << endl;
  61.  
  62.             cin >> animal_choice;
  63.             if (adoption_budget >= pet_prices[animal_choice-1]) {
  64.                 switch (animal_choice){
  65.                     case 1:
  66.                         cout << "You have chosen a small dog for $25!" << endl;
  67.                         adoption_budget -= 25;
  68.                         amount_spent += 25;
  69.                         animal_amt +=1;
  70.                         break;
  71.                     case 2:
  72.                         cout << "You have chosen a medium dog for $40!" << endl;
  73.                         adoption_budget -= 40;
  74.                         amount_spent += 40;
  75.                         animal_amt +=1;
  76.                         break;
  77.                     case 3:
  78.                         cout  << "You have chosen a large dog for $65!" << endl;
  79.                         adoption_budget -= 65;
  80.                         amount_spent += 65;
  81.                         animal_amt +=1;
  82.                         break;
  83.                     case 4:
  84.                         exit = true;
  85.                         break;
  86.                 }
  87.             }
  88.             else if (animal_choice == 4){
  89.                 exit = true;
  90.             }
  91.             else{
  92.                 cout << "Sorry but you cannot afford that option." << endl;
  93.             }
  94.  
  95.         } while ((adoption_budget >= amount_spent) && (exit == false));
  96.         cout << "You have bought " << animal_amt << " dog(s) with $" << adoption_budget << " remaining.";
  97.            
  98.     }
  99.    
  100.     return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement