Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ 10. A function to which you pass the number of hours slept, the distance walked (i.e. total number of steps) as determined by

in c++
image text in transcribed
image text in transcribed
image text in transcribed
10. A function to which you pass the number of hours slept, the distance walked (i.e. total number of steps) as determined by option 1 , and the number of pills as determined by option 2. It will return the number of minutes for a nap according to: minutes=hrsslept+distwalkedumberofpills(if0,divideby1) 11. A function to output the number of minutes for a nap. It will have one parameter. 12. A function which prompts for and reads in the user's weight, height, and room temp (along with the distance walked), then computes and returns calories according to the formula cals=6wt+2ht+1/(temp)+dist.walked 13. A function to which you pass the value from #12 above and it will output it, For the foregoing functions, if they are to prompt and input values, they should "cleanse input" with reasonable limits. For example, prompting for a weight should reject responses that are non-positive and those over 800lbs. When you submit: When you submit, you are all to enter the same information so as not to drive the graders crazy. You can test your code following these steps: - choose option 3 (better get an error message!) - choose option 4 (get an error message) - choose option 1 and enter 6 ( 6 legs for the walk) - choose option 3 (again, errorl) - choose option 2 and enter anxiety of 3 and day 5 - choose option 3 and enter 5 hrs sleep - choose 4 and enter 250lbs,72 inches, and 79.7F. And, as always, let your instructor know if you need any help. 1. When the user chooses option 1, the program should prompt for and read in the number of "legs" of the walk the user wishes to have. The total number of steps from the "legs" should be computed and displayed. 2. Option 2 chosen will trigger prompts for the user to input their current anxiety level (from 1 to 10 ) and the day of the week (from 1 to 7). From this information, the program will compute and output the number of pills the user should take that day!. 3. If option 3 is chosen, your program is to REFUSE to do anything if both options 1 and 2 haven't yet been chosen during that run of the program. That is because the computations for option 3 require the information from options 1 and 2 . Now, if options 1 and 2 have indeed been chosen, then your program code for option 3 starts by prompting the user for the number of hours they slept the previous night. This information, along with the computed values from options 1 and 2 , will be used to compute and output the number of minutes you may nap for. 4. Choosing option 4 will initiate prompts for body weight, body height, and room temperature. From this, the code should compute and output caloric intake allowable at that moment. It uses the result from Step 1 and hence, should raise an error if option 4 is chosen before option 1 in the same run. 5. Choosing quit will terminate the program.... of course. Detalls: First, you are required to use the switch statement for handling the options chosen from the menu. Secondly, you will use functions for the program and they are laid out here: 1. A function that does nothing more than displaying the greeting for the program. It shoul have no parameters and return nothing. returns it to the main function. It should Nor "in the swite in main. 3. A function that will prompt for and read in a positive integer for the number of legs of the walk. This (cleansed) value is returned to the calling function (presumably main). 4. A function to which you pass the value retumed by the preceding function, and it will output the total number of steps according to: total number of steps =( number of legs) ) ! e. if number of legs is 4 , then total number of steps =4!=4321=24 steps. 5. A function that prompts for and reads in anxiety level (valid input is 1>10 ) and returns it. 6. A function that prompts for and reads in the day (valid input is 1>7 ) and returns it. 7. A function to which you pass the two values above (anxiety and day) and it returns the number of pills the uter should take according to: numberofpills={abxictyday,if(anxietyday)>00.otherwise 8. A functive to which you pass the number of pills and it will output it to the sereen. 9. A function that prompts for and reads in the number of bours slept the previous night. Due: Thursday, Mar. 2, 2023 by 23:59 100pts Instructions: Create a subdirectory named "hwl" in your cs410 directory. Use that subdirectory for all your file submissions on this assignment. At the end of the homework assignment, these two files should be found in your hwl directory: 1. a single C+ compilable file containing a program written in C++ named "hwl.cpp" 2. a "typescript" file demonstrating program compilation, execution and testing. Use the commands below at the UNIX prompt to generate the typescript file in this order: - script command to start a typescript. - Is - t to list files in your directory and write date/time - cat hw1.cpp to print out solution file - g++0 hw1 hwl.epp to compile program - Ahwl to execute program - exit command to end typescript file Background: In this assignment, you are going to write a menu driven program to help Krusty out with his "health managenent issues".Yep, indeed, it's no longer enough to just take care of yourself by eating right and getting enough exercise. You had better spend a lot of money, have a personal health trainer, a membership to a gym, take way too many pills and subseribe to every hair-brained self-help scheme alive. But I digress. This program will present the user with several options concerned with improving health in varied manners. The user will choose an option, following instructions about prompted information, receive the intended recommendation, and then have the menu presented to them once again. Of course, the user can quit at any point. Your code will be implemented using functions. Now you will have your practice with them. Specifications: You are to use functions in the program. In fact, below is a description of the functions we want you to use. Your program will present a greeting and menu of options to the user, It should look something like this: Health-o-Matic Options 1. Taking a Walk! 2. Your Medications 3. Nap Timel! 4. Calonic Intake. 5. Quit

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago