Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Add code to your program from assignment 2 so that you can verify user input, and respond more specifically to the user's input. Produce different
Add code to your program from assignment 2 so that you can verify user input, and respond more specifically to the user's input. Produce different output messages depending on the input that the user provides.
As an example, if you asked for the user's age, then based on the age, you can respond in different ways, like this:
Age Output
>120 "invalid age"
0-2 "what a cute baby"
3-6 "Let's play hide and seek"
7-11 "Let's play minecraft"
12-17 "Let's play five nights at freddy's"
18-22 "First time voting!"
18-24 "How's school?"
31-55 "How's work?"
56-99 "How's retirement?"
100-120 "Oldest Ever!"
Note that some ranges may overlap. You should include something like this (overlapping ranges) in your code; you will need to use nested if statements to handle that situation.
Respond to at least one numerical question and at least one text question. Responding to the text question will require giving the user a choice of options, and verifying that the input is one of the available options. Use a loop to keep asking the user until they give one of the options, like this:
Are you feeling happy today? (yeso/unsure)
> pretty happy
Please answer with one of the available options.
Are you feeling happy today? (yeso/unsure)
> Yeppers
Please answer with one of the available options.
Are you feeling happy today? (yeso/unsure)
> yes
Great! glad you are happy.
In addition to a screenshot, you should generate an output log file. This means that for every input the program receives, that input should be sent to the output file (an echo), and that every output that the program generates should be displayed to the screen AND sent to the output file. For example, for every line that starts with cout
ooo Fido 69% 5:15 PM urcourses.uregina.ca Question 1 97 2 4848 2 24 24/2 12 12/2 6 6/2 3 3 2 1 1/2-0 Answer: 97 1100001 b) 10100101 10100101 2 (1.27+0.2 +1.2 +0 2 0.2 +1.22+0 2 +1.2012 (128 +0+32 +0+0+4 0 112 Answer: 10100101 165 Question 2 a) float subTotal, percentTip, totalBill; total Bill (1.0 percent Tip 100.0) SubTotal b) The dodecahedron has a volume indicated by the following formula: y where a is the length of an edge in C++, the formula for this would be: float edge //edge length float dodecArea; area of the dodecahedron dodecArea (15.0+7.0 sqrt(5.e))/4.0) edge edge edge where the library "cmath would be required for the "sqrt0 function By building a log file in this way, you can do multiple test of input and output without having to find a way to fit them all on your screenshot. When you submit your code, provide a copy of your log file as well as a copy of your .cpp file, in order to show the test cases you used. Indicate (in your assignment file or comments) which test cases you chose and why.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started