Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with this C++ beginning assignment, please. limerick.cpp 59 Consider the following poem: A dozen, a gross and a score d; and three
I need help with this C++ beginning assignment, please.
limerick.cpp 59 Consider the following poem: A dozen, a gross and a score d; and three times the square root of four divided by seven plus five times eleven is nine squared and not a bit more. Suppose I don't know how much a dozen, a gross or a score is. I'm going to use a program you create to search for values for these variables such that the above poem is true. Your main() should ask the user to enter values for dozen, gross and score and then calculate the left-hand-side (LHS) of the above poem using the supplied values. The LHS is all the terms before the "is". Thus your program should print the quantitative result of the calculation: 3 * dozenlgmssl;score+ +5*11 Prompt the user for values as follows: Enter a value for dozen: 6; Enter a value for gross: 6; Enter a value for score: 6; There must be one space after each colon and no newline. You must accept console input on the same line as the prompt. With appropriate values, the result should be 81, as poetically described above, but your program needs to correctly evaluate the expression above regardless of what values are used for dozen, gross and score. Use parentheses in the above expression to make sure you get the operand groupings correct and confirm your program calculations by hand with various inputs. You are allowed to use the cmath library function sqrt(). (And if that sounds mysterious, feel free to ask in our class discussions, or office hours, or Stem Center tutoring.) Lastly, output the result to the console as follows: For the provided values of _ and the result is ____. d; ___: ____ . ____ . Your output will of course fill in the missing values, and it should have one newline after. etox.cpp c3 This program should print the value of 51 where the value should be calculated as the sum of exactly the first five terms in its expansion below: 2 3 e$:1+m+%+j+m where n! is the factorial of n, which is the product of all positive integers at most equal to n: You would therefore return the result of the calculation: 2 3 4 1+m+%+%,+%, Keep it simple and don't overcode. Simply use numeric literals in place to calculate the factorials. In your main(), prompt the user for an integer value of x as follows: Enter an integer value for x: LL] There must be one space after the colon and no newline. You must accept console input on the same line as the prompt. Read the user's response into a variable, calculate em, and print the value to the console followed by a single newline as follow: Your output will fill in the missing blanks of course. Oh, and let's say NO using the [HMO function from cmath , let's do it by hand, so to speak (just use repeated multiplication). Oh, and why not format the double output so it looks pretty with precision to three decimal places. (hint: it's in the modules.) int dozen, gross, score; / /Asking the user for variables dozen, gross and score. cout > dozen; cout > gross; cout > score; //Calculating the left-hand-side (LHS) value of the poem double Lhs = (((dozen + gross + 3 * sqrt(4) ) ) / 7) + (5 * 11) ; // Output the result cout 2 #includeStep 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