Question

Requirements: The first part of the program will require user input that indicates whether the user...

Requirements:

  • The first part of the program will require user input that indicates whether the user will adopt based off of a certain amount of dogs or based off of a budget.
  • If the user enters 1, then they will be prompted to enter the amount of dogs they would like to adopt.
  • If the user enters 2, then they will be prompted to enter their budget amount (integer).
  • For both options 1 and 2, a menu will be prompted asking if the user would like a small dog ($25), medium dog($40), or a large dog($65) by inputting 1, 2, or 3 respectively.
    • If the user had chosen a certain amount of dogs to adopt, then the user will be able to choose either sizes until they reach their chosen amount. The program will then output the total price they paid for the amount of dogs they originally specified to adopt.
    • If the user had chosen a budget, then the user will be able to buy until they can no longer buy the cheapest dog or they decide to quit. The program will then output the amount of dogs purchased and their remaining budget (even if it is $0).

Additional Notes:*

  • When prompted for an input for an option, we will only enter in numbers within that range. EX) We won't enter in 10 when only options 1 and 2 are present.
  • You will be using both for- and while-loops.
  • While using the budget option, if the amount entered or if the remaining budget is less than $25, then the loops should end. Also, users should be outputted an error when trying to adopt a dog that is higher than their current budget.

Example:

Please select an adoption process:
1) Adoption by animal amount
2) Adoption by budget
**1**
Enter the amount of animals you are adopting: **2**
Which dog would you like to adopt?
1) Small dog ($25)
2) Medium dog ($40)
3) Large dog ($65)
**1**
You have chosen a small dog for $25!
Which dog would you like to adopt?
1) Small dog ($25)
2) Medium dog ($40)
3) Large dog ($65)
**3**
You have chosen a large dog for $65!
Your final total is $90 for 2 dog(s).
Please select an adoption process:
1) Adoption by animal amount
2) Adoption by budget
**2**
Enter your adoption budget: $**50**
Which dog would you like to adopt?
1) Small dog ($25)
2) Medium dog ($40)
3) Large dog ($65)
**3**
Sorry but you cannot afford that option.
Enter your adoption budget: $**50**
Which dog would you like to adopt?
1) Small dog ($25)
2) Medium dog ($40)
3) Large dog ($65)
**2**
You have chosen a medium dog for $40!
You have bought 1 dog(s) with $10 remaining.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

#include <iostream>
using namespace std;


void displayMenu();
int main() {

int choice, animalChoice, total = 0,n,budget,cnt=0;
cout << "Please select an adoption process:" << endl;
cout << "1)Adoption by animal amount" << endl;
cout << "2)Adoption by budget" << endl;
cin >> choice;

if (choice == 1){
cout<<"Enter the amount of animals you are adopting:";
cin>>n;
for(int i=0;i<n;i++)
{
   displayMenu();
   cin>>choice;
   switch(choice)
   {
       case 1:{
           cout<<"You have chosen a small cat for $25!"<<endl;
           total+=25;
          
           break;
       }
       case 2:{
           cout<<"You have chosen a medium cat for $40!"<<endl;
           total+=40;
          
           break;
       }
       case 3:{
           cout<<"You have chosen a large cat for $65!"<<endl;
           total+=65;
          
           break;
       }
      
   }
}
  
cout<<"Your final total is $"<<total<<" for "<<n<<" cat(s)."<<endl;
}

else if (choice == 2){
cout<<"Enter your adoption budget: $";
cin>>budget;
  
while(budget>=25)
{
displayMenu();
cin>>choice;
  
switch(choice)
{
   case 1:{
       if(budget>=25)
       {
           cout<<"You have chosen a small cat for $25!"<<endl;
budget-=25;
cnt++;
       }
       else
       {
       cout<<"Sorry but you cannot afford that option."<<endl;  
       }
       break;
   }
   case 2:{
       if(budget>=40)
       {
           cout<<"You have choosen a medium cat for $40!"<<endl;
           budget-=40;
           cnt++;
       }
               else
       {
           cout<<"Sorry but you cannot afford that option."<<endl;
       }
       break;
   }
   case 3:{
       if(budget>65)
       {
           cout<<"You have choosen a large cat for $65!"<<endl;
           budget-=65;
           cnt++;
       }
               else
       {
              cout<<"Sorry but you cannot afford that option."<<endl;
       }
       break;
   }  
}
  
  
}
  
cout<<"You have bought "<<cnt<<" cat(s) with $"<<budget<<" remaining."<<endl;
}
return 0;
}

void displayMenu()
{
   cout<<"\nWhich cat would you like to adopt?"<<endl;
   cout<<"1) Small cat ($25)"<<endl;
   cout<<"2) Medium cat ($40)"<<endl;
   cout<<"3) Large cat ($65)"<<endl;
}

=================================

Output#1:

===============================

Output#2:

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Requirements: The first part of the program will require user input that indicates whether the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • **IN JAVAA** Write a program where a user populates a collection of various cats and dogs....

    **IN JAVAA** Write a program where a user populates a collection of various cats and dogs. The user should be able to specify which type they wish to enter, and then are prompted with the pertinent information for every type of pet.    Requirements: The structure of the program should follow this UML class diagram. You may also include helper methods and attributes that are not noted in the class. Additional Notes: The weight for animal should be strictly greater...

  • In Small Basic Write a program that asks the user how many numbers s/he wishes to...

    In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...

  • Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate....

    Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate. ·         The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. ·         The application prompts the user to continue. ·         The program stops prompting the user for values after taking 3 loan amounts. ·         The application calculates and displays the total loan and interest amount and ends the program Example Output Welcome to...

  • Write a Visual C# program that will input the user's name and a message. The user...

    Write a Visual C# program that will input the user's name and a message. The user will be able to choose from an option of formatting tools to change the way the message (and only the message) will look. The user can choose from bold, underline, italic, along with several different color options. All changes the user selects will be displayed in the message textbox. Once the user selects the Finish button, the two pieces of information entered by the...

  • PART TWO Write a program which will populate an integer ArrayList with user input, and then...

    PART TWO Write a program which will populate an integer ArrayList with user input, and then provide a menu of various operations to perform on that ArrayList. The first step is to have the user push a bunch of integers into a ArrayList. The second step is to perform various operations on that ArrayList. Your input must be in the format below. The user can enter either a positive integer or -99 to quit. The menu to present is: Sum...

  • Write a program in python that asks the user to input a sentence. The program will...

    Write a program in python that asks the user to input a sentence. The program will ask the user what two letters are to be counted. You must use a “for” loop to go through the sentence & count how many times the chosen letter appears in the sentence. You are not allowed to use python built-in function "count()" or you'll get a Zero! Output will show the sentence, the letter, and the number of times the letter appears in...

  • Question 1 ^ 2 What is the main point of the passage? 3 What will happen...

    Question 1 ^ 2 What is the main point of the passage? 3 What will happen if someone shows up before opening? 4 What would happen if a dog owner showed up and had food? 5 what would happen if someone had toys and food outside the park gates? "BARK IN THE PARK GRAND REOPENING EVENT Join us on Saturday from 11am to 3pm at Meadowview park for the grand reopening of the newly renovated de park to celebrate the...

  • e TailSpin Pet Supply Company (TailSpin) is a le company that purchases dog beds manufacturer and resell...

    e TailSpin Pet Supply Company (TailSpin) is a le company that purchases dog beds manufacturer and resells them to retail small e company has three inventory items: g beds, medium dog beds, and large dog TailSpin uses a perpetual inventory system, method. They own land with a building, which into office and warehouse space. All expenses th the office are categorized as Administrative Expenses. All FIFO is divided associated expenses with the warehouse, which is used for the shipping and...

  • write a c++ program that prompts a user for a number then attempts to allocate an...

    write a c++ program that prompts a user for a number then attempts to allocate an array of as many integers as the user enters. In other words, the program might prompt the user with a line like: “How many integers would you like to allocate?” It should then allocate as many integers as the user enters. The program should then wait for the user to press enter before deleting the allocated array and quitting. We will use this time...

  • The Task: Create a console application that prompts the user to select either a stack, queue,...

    The Task: Create a console application that prompts the user to select either a stack, queue, linked list, or binary search tree. Then prompt the user for a number that will then be passed to a recursive function that will populate an array in ascending order. If user selected binary search tree, they will then be prompted to choose how the data will be received either in-order, preorder, or post-order. If user selected linked list, they will then be prompted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT