Concept explainers
Write a program in C++ to help Buddy (the sheepdog) calculate the average age of all his sheep. The
program will accept as many ages as Buddy needs to input. The program should help Buddy
minimize input errors by error-checking the age for him (everybody knows the maximum age for
cartoon sheep is 9 years old). When Buddy’s sheep start to get old, he needs to breed more
sheep. So, the code should also let Buddy know if the average age indicates if his sheep are aging,
young, or middle-aged based on the chart below:
average Sheep Age Population is…
<= 3 Young
4 - 6 Middle-aged
> 6 Aging
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Write an improved version of the futval . py program from Chapter 2.Your program will prompt the user for the amount of the investment, theannualized interest rate, and the number of years of the investment. Theprogram will then output a nicely formatted table that tracks the value ofthe investment year by year. Your output might look something like this: Year Value----------------0 $2000 . 001 $2200 . 002 $2420 . 003 $2662 . 004 $2928 . 205 $3221 . 026 $3542 . 127 $3897 . 43arrow_forwardWrite a C++ program for the following. In each plastic container of Pez candy, the colors are stored in random order. Your little brother only likes the yellow ones, so he painstakingly takes out all of the candies, one at a time, eats the yellow ones, and keeps the others in order so he can return them to the container in exactly the same order as before, minus the yellow candies, of course. Write a program to simulate this process. You must use Nyhoff's stack class; other solutions including the use of the STL stack class are unacceptable. Assume that the candies are denoted as Y for yellow, B for blue, R for red, O for orange. Your program is to query the user for ten letters (representing ten Pez candies), and after using appropriate stack operations, display the contents of the container minus the yellow candies. The order in which the letters are entered is the order that they were removed from the Pez container. When your answer is displayed the results must be in the same…arrow_forwardHello, This is part of my hangman simulation in C++. If you compile and run it and type "Easy," the code should run. If you run it though, the body of the hangman doesn't align when you guess wrong. Could you help me with that and implement an if statement to repeat the program if user wants to play again? #include <iostream> #include <cstdlib> #include <ctime> #include <string> #include <iomanip>using namespace std; const int MAX_TRIES = 5;char answer; int letterFill(char, string, string&); int main() { string name; char letter; int num_of_wrong_guesses = 0; string word; srand(time(NULL)); // ONLY NEED THIS ONCE! // welcome the user cout << "\n\nWelcome to hangman!! Guess a fruit that comes into your mind."; // Ask user for for Easy, Average, Hard string level; cout << "\nChoose a LEVEL(E - Easy, A - Average, H - Hard):" << endl; cin >> level; // compare level if (level == "Easy") {//put all the string inside…arrow_forward
- Write a C program that compute the perimeter of Circle, Rectangle, Triangle and Square. The program asks the user to specify the shape as follows: C for Circle, S for Square, R for Rectangle and T for Triangle and then it reads the required value to compute the perimeter for that specified shape. Note: the perimeter for the shapes:????l? = ? × ?????? × ?S????? = ? × ????????????? = ? × (????? + ??????) ???????? = ????? + ????? + ????3arrow_forwardIn C++ only Today is the birthday of Rajesh. He wants to buy sweets for his friends so he went to the Chef sweet shop. He has X amount of cash with him. The pricing of sweets is as follows. If he selects N sweets and places them in a single line then the price of the ith sweet from left is i². He wants to maximize his purchase of sweets to share with his friends. Can you help him? Chef has a total of 106 sweets. Input 1 42 Output 4arrow_forwardIn Java: Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education