Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

GE 1501 Fall

C++: A World Without Lemons

Summary:

The world is running out of lemons and we have discovered an ancient code to make the ritual circle. In order to decipher the code, we must find the solutions to the problems below. Each problem will give you a coordinate to make the ritual drawing. You must get 5 problems correct to unlock enough coordinates to complete the ritual. Draw the final shape in AutoCAD and then unlock the box at the front of the room!

Skills to be Obtained:

- Use your mastery of C++ to solve the following problems

- Implement Loops, Branching, Functions, and C++ fundamentals

- Use AutoCAD and logic to solve the bigger puzzle

Details:

Please work with up to one partner on this assignment. To win the game and earn full credit, you have to determine the ritual drawing which leads you to the secret 3-digit code to open the box at the front of the class (solve 5 out of 8 problems below). The ritual drawing is hidden using a cryptographically strong mechanism known as Secret Sharing. The technique allows a secret to be distributed among many people such that none of them have any idea what the secret is until more than one of them come together with their share of information.

Background:

Secret Sharing: A cryptographically weak way to share the code word “secret” among two people is to give the first person “sec---“ and the second person “---ret”. If they come together, they can recreate the whole word. This simple secret sharing technique is very weak, since both people already know half of the secret even before getting together with the other partner. In fact, either person probably could have guessed the code word without too much difficulty.

In Secret Sharing, the secret remains completely hidden from everyone until the required number of people assemble. But, as soon as the required number of people each give their share of information, the secret becomes fully revealed. It is also very flexible, in that you can choose how many people have to assemble to revel the secret. In fact, you can give shares of the secret to as many people as you like, and still no one will have any idea what the secret is until the right number of them assemble and provide their shares. For example, you could give a share of the secret to 8 people, requiring any 4 of them to contribute the data they were given in order to determine the secret.

Assignment:

In today’s game, the launch code has been “shared” among eight people. We’ve given 1 share to each of the following; old wizard, hungry dragon, pondering ogre, thieving kender (hobbit with a stealing problem), patrolling gargoyle, bloodthirsty princess, devious lich, and forgetful scribe. Only when at least 5 of these 8 people agree to give you their share of the secret can you solve the problem.

You and your partner need to obtain 5 shares of the secret and connect them to make a drawing with AutoCAD, (i.e., 5 Cartesian (x, y) points) and then determine the corresponding 3-digit lock code. Obtaining a share of the secret is accomplished by solving 1 of the problems listed on the next page. Show me a solution to 1 of the problems, and I’ll give you that person’s share of the secret. Keep that information secure!

For each problem you wish to solve, write a C++ code that answers the questions or a list of the errors (for the scribe). You may use class notes or Canvas to help, but you may not use Google or other Internet resources. As soon as you have 5 shares of the secret, you can determine the ritual drawing and then the 3-digit code and you have won the game.

Submission Requirements:

After obtaining 5 shares of the secret, show them to me and let me see it run.

Extended Work:

If you wish, you can continue and solve all eight of the problems listed on the next page by the end of class. There is no partial credit for this option. To obtain extra credit, obtain all eight shares of the secret by solving each of the problems and then draw the ritual in AutoCAD.

Problems:

Each of the eight people listed below have been given one (x, y) point. Show me a script that solves the problem and outputs the correct answer, and I’ll give you that person’s point.

Old Wizard: I cannot remember my basic math. What is the sum of all numbers between 0 and 500 not divisible by 2? Remind me and I will reward you with a coordinate.

Pondering Ogre: I have been pondering perfect squares as of late, but I can only count up to 500. What is the biggest perfect square that I can count up to? (hint: if the number is below 60, you are giving me the square root of the number, no the perfect square itself!)

Thieving Kender: I have recently stolen two wonderful functions to make my brand new flag! Please write me a program that uses my functions to output the following flag (copying “” with CLion work poorly. I suggest retyping them.):

void star (int i) void space (int i)
{    for (int j = 0; j{   for (int j = 0; j

cout<<"*"; } cout<<" "; }

**  **
****
***  ***
Zoomed in:

*

*

*

*

*

*

*

*

*

*

*

*

*

*

Patrolling Gargoyle: There are 699 stone steps on my nightly patrol. I start on stone step 7. If I only ever step on every 7th stone step, how many complete cycles will I need to make before I step on the 698th stone step? A cycle finished once the gargoyle passes 699. When this happens, carry over the extra steps, so 700 becomes 1, 701 becomes 2, etc.

Bloodthirsty Princess: Princess is defending her nations from a zombie. She wants to make sure she does not waste any effort to kill each zombie so she deals exactly 30 damage to each zombie (killing it). She can stab it with a sword and deal 7 damage, a dagger to deal 5 damage, or kick it in the shin for 2 damage. Zombies can only be hit using functions (exactly 3 total). Write a program showing the princess killing the zombie that outputs her combat and damage totals as the zombie is slain. You can use any combination of attacks as long as they total to 30 damage!

Hungry Dragon: I am hungry for some bread but will only eat right triangular slices with uniquely sized sides. I can only fit pieces with the longest side less than 100 units long in my mouth. How many Pythagorean triples (e.g. 3, 4, 5 or 6, 8, 10) have a hypotenuse less than 100? (All unique triples but no repeats (if you have 3, 4, 5 then do not count 4,3,5) – warning, this problem is deceptively hard!).

Devious Lich: This person has requested you to uncover the potion’s composition. Make a function that takes a user integer input from the main code. Inside the function, you must figure out the potion’s composition.

· First divide by 100 and output that the number of phoenix feathers is equal to the quotient (as an integer) and pass the remainder on to the next step.

· Then divide by 48 and output that the number of newt eyes is equal to the quotient (as an integer) and pass the remainder on to the next step.

· Next, check to see if the remainder is odd. If it is, subtract 4 from the remainder and pass that value onto the next step.

· Lastly, check to see if the remainder is exactly 17 and you have equal to or greater than 1 each for newt eyes and phoenix feathers.

If so, you have made an Elixir of New Lichdom. Congratulate the user if they made the Elixir of New Lichdom! Run this with the smallest possible number that will give them the Elixir of New Lichdom and show me the output!

Forgetful Scribe: I was copying this program from an esteemed associate, but it does not work. Apparently, I mis-scribed my transcription (on the next page). Please find my 5 errors and fix them for me! (All errors will be pieces of C++ that you are familiar with!)

#include

using namespace std;

int main {

cout << setiosflags(ios_base::fixed) // do not use E notation

<< setiosflags(ios_base::showpoint) // always show decimal point

<< setprecision(2); // rounded to 2 decimal places

double x1, y1, x2, y2, rise, run, slope, c;

cout << "Enter value for x1, y1:" << endl; // Get input from user

cin >> x1 >> y1;

cout << "Enter value for x2, y2:" << endl; // Get input from user

cin >> x2 >> y2;

rise = y2-y1;

run = x2-x1;

if (y2-y1 == 0 && x2-x1==0)

{

cout << "These points do not form a line." << endl;

}

else if (y2-y1 = 0)

{

cout << "This line is horizontal" << endl;

}

else if (x2-x1 == 0)

{

cout << "This line is vertical" << endl;

}

else

{

slope = rise/run

c = y1 - slope*x1;

cout << "The slope of these two points is = " << slope << endl<

cout << "The intercept of the line is = " << c << endl<

cout << "The equation is y = "<< slope << "x + " << c << endl;

return 0;

}