Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Loopy Zebras In this quest, you get to play with looping. You will create a bunch of functions, each of which does something that requires
Loopy Zebras
In this quest, you get to play with looping. You will create a bunch of functions, each of which does something that requires you to iterate over a sequence of steps more than once.
Each of these functions is worth a varying number of points. It's up to you to find out how many points you can score by making the most progress you can.
As usual, I will give you template code you can copy and flesh out.
Important note
In miniquests where you have to calculate the value of some fractional quantity and gp terms you may not use the Math library methods eg sqrt pow, etc If you do you'll find that your results may be very slightly different from mine. They have to match exactly for you to pass the miniquests. There's the challenge.
Your first miniquest Guess it
To get past this checkpoint you must correctly implement the following function in the template code:
bool playgameint n;
When I invoke this method, I will supply it an integer parameter, which you must treat as a secret number.
Then you must give the user chances to guess the number using the exact script below:
As soon as the function begins, print the following on the console to greet the user:
Welcome to my number guessing game
followed by exactly two blank newlines.
Recall that an AP is specified by two terms a and The first term is a and the is how much you add to each term to get the next term. So the first terms of the above AP will be:
Suppose, for example, that and Then this function should return the string
Page of
Note some important things about the returned value: There are no newlines or spaces. Only commas separate the numbers. There is NO comma before the first number or after the last number. The format has to match exactly.
Your sixth miniquest Terms of a GP
Copy and adapt the function in the previous miniquest to turn it into a function that returns the terms of a geometric progression, rather than an arithmetic one. We're talking about changes to a couple of lines.
However, note that the parameter types are different. You should operate in double space to keep high precision not in integer space
Recall that a GP is specified by two terms a and The first term of the sequence is and the is by how much multiply each term to get the next term. So the first terms of the above AP will be:
Loopy Zebras
In this quest, you get to play with looping. You will create a bunch of functions, each of which does something that requires you to iterate over a sequence of steps more than once.
Each of these functions is worth a varying number of points. It's up to you to find out how many points you can score by making the most progress you can.
As usual, I will give you template code you can copy and flesh out.
Important note
In miniquests where you have to calculate the value of some fractional quantity and gp terms you may not use the Math library methods eg sqrt pow, etc If you do you'll find that your results may be very slightly different from mine. They have to match exactly for you to pass the miniquests. There's the challenge.
Your first miniquest Guess it
To get past this checkpoint you must correctly implement the following function in the template code:
bool playgameint n;
When I invoke this method, I will supply it an integer parameter, which you must treat as a secret number.
Then you must give the user chances to guess the number using the exact script below:
As soon as the function begins, print the following on the console to greet the user:
Welcome to my number guessing game
followed by exactly two blank newlines.
Recall that an AP is specified by two terms a and The first term is a and the is how much you add to each term to get the next term. So the first terms of the above AP will be:
Suppose, for example, that and Then this function should return the string
Page of
Note some important things about the returned value: There are no newlines or spaces. Only commas separate the numbers. There is NO comma before the first number or after the last number. The format has to match exactly.
Your sixth miniquest Terms of a GP
Copy and adapt the function in the previ
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