Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
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 #include 3 #include 4 #include 5 using namespace std; 6 7 double eval_limerick(int dozen, int gross, int score) { 8 double result = dozen + gross + score + (3 * sqrt(4) ) / 7 + 5 * 11; 19 return result; 10 } 11 12 . int main(int argc, char **argv) { 13 int dozen, gross, score; 14 if (argc > dozen; 19 istringstream(argv[2]) >> gross; 20 istringstream(argv [3]) >> score; 21 22 double limerick_result = eval_limerick(dozen, gross, score) ; 23 24 if (limerick_result == 81) { 25 cout

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Scope of environmental science short brief ?

Answered: 1 week ago

Question

Ecology and economy ?

Answered: 1 week ago