Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int adoption_process, adoption_amt, animal_amt, animal_choice, total_fee;
- int adoption_budget, amount_spent;
- cout << "Please select an adoption process:" << endl;
- cout << "1) Adoption by animal amount" << endl;
- cout << "2) Adoption by budget" << endl;
- cin >> adoption_process;
- /* adoption by animal amount */
- if (adoption_process == 1) {
- cout << "Enter the amount of animals you are adopting: " << endl;
- cin >> adoption_amt;
- for (animal_amt=0; animal_amt < adoption_amt; animal_amt += 1){
- cout << "Which dog would you like to adopt?" << endl;
- cout << "1) Small dog ($25)" << endl;
- cout << "2) Medium dog ($40)" << endl;
- cout << "3) Large dog ($65)" << endl;
- cin >> animal_choice;
- switch(animal_choice){
- case 1:
- cout << "You have chosen a small dog for $25!" << endl;
- total_fee += 25;
- break;
- case 2:
- cout << "You have chosen a medium dog for $40!" << endl;
- total_fee += 40;
- break;
- case 3:
- cout << "You have chosen a large dog for $65!" << endl;
- total_fee += 65;
- break;
- }
- }
- cout << "Your final total is $" << total_fee << " for " << animal_amt << " dog(s).";
- }
- /* adoption by budget */
- else {
- cout << "Enter your adoption budget: $" << endl;
- cin >> adoption_budget;
- int pet_prices [3] = {25, 40, 65};
- animal_amt = 0;
- bool exit = false;
- do {
- cout << "Which dog would you like to adopt?" << endl;
- cout << "1) Small dog ($25)" <<endl;
- cout << "2) Medium dog ($40)" << endl;
- cout << "3) Large dog ($65)" << endl;
- cout << "4) Exit" << endl;
- cin >> animal_choice;
- if (adoption_budget >= pet_prices[animal_choice-1]) {
- switch (animal_choice){
- case 1:
- cout << "You have chosen a small dog for $25!" << endl;
- adoption_budget -= 25;
- amount_spent += 25;
- animal_amt +=1;
- break;
- case 2:
- cout << "You have chosen a medium dog for $40!" << endl;
- adoption_budget -= 40;
- amount_spent += 40;
- animal_amt +=1;
- break;
- case 3:
- cout << "You have chosen a large dog for $65!" << endl;
- adoption_budget -= 65;
- amount_spent += 65;
- animal_amt +=1;
- break;
- case 4:
- exit = true;
- break;
- }
- }
- else if (animal_choice == 4){
- exit = true;
- }
- else{
- cout << "Sorry but you cannot afford that option." << endl;
- }
- } while ((adoption_budget >= amount_spent) && (exit == false));
- cout << "You have bought " << animal_amt << " dog(s) with $" << adoption_budget << " remaining.";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement