Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Exercise #4 The Cat's Calories Write a program to simulate the energy of a cat. The cat starts with C calories of energy. When

c++ image text in transcribed
Exercise \#4 The Cat's Calories Write a program to simulate the energy of a cat. The cat starts with C calories of energy. When it walks for one hour, it burns B calories. After walking, the cat has to eat for one hour, and will gain E calories. After eating, it goes back to walking. And, so on, as long as it has energy. Your program should prompt the user to enter values for C,B, and E. Then the program produces the hour-by-hour progress for the cat, and finally prints the total number of hours needed for the cat's energy to reach zero. The cat stops walking or eating when the energy is zero or less. Sample inputs / outputs: Welcome to the cat energy simulation. Enter values for C, B, and E separated by spaces: 942 The following is your cat's hour-by-hour progress: Hour 1 - Walking - Remaining Energy (94=5) Hour 2 - Eating - Remaining Energy (5+2=7) Hour 3 - Walking - Remaining Energy (74=3) Hour 4 - Eating - Remaining Energy (3+2=5) Hour 5 - Walking - Remaining Energy (54=1) Hour 6 - Eating - Remaining Energy (1+2=3) Hour 7 - Walking - Remaining Energy (34=1) The cat will stop after 7 hours

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions