Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm having trouble writing this code in c++. When I submit my answer, it says I output the wrong numbers even when I run the
I'm having trouble writing this code in c++. When I submit my answer, it says I output the wrong numbers even when I run the program myself it works. I might be missing something but please help me.
Consider the following poem: A dozen, a gross and a score and three times the square root of four divided by seven plus five times eleven is nine squared and not a fit more. Suppose I don't know how much a dozen, a gross or a score is. I'm going to use a function you create to discover values for these variables such that the above poem is true. In a file called Limerick.cpp, flesh out the function: double eval_limerick(int dozen, int gross, int score); It should calculate the left-hand-side (LHS) of the above poem using the supplied values for dozen, gross and score and return the result. The LHS is all the terms before the "is". Thus your function should return the quantitative result of the calculation: dozen+gross+score+3sqrt(4)/7+511 But before you jump the gun, make sure to calculate it by hand and confirm that you correctly get the RHS (81). Use parentheses in the above expression to make sure you get the operand groupings that make the poem come true. You are allowed to use the math library function, sqrt () . Note: Yes. I know that you can implement the function using non-intuitive values for these quantities and still pass the test. Just use common sense values. It's more fun that way. \#include /// Need this for istringstream below \#include // needed for sqrt \#include // for exit() using namespace std? double eval limerick(int dozen, int gross, int acore) \{ //Todo- Your code here b // I'm using command line arguments below to let me test your program with // various values from a batch file. You don't have to know the details for //cs2A, but you're welcome to - Discuss in the forums any aspect of this // program you don't understand. int main (int argc, char *argv) f int dozen, gross, score: if ( argaStep 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