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

GE 1501

Fall

C1: All this machinery making modern codes

Summary:

You are working in a puzzle factory making randomized solutions based on a sequence of letters. The rotational lock can only use letters A-G. Instead of choosing by hand, you decided to create an algorithm and lets the process “choose” which letters are used in the code. Part of the process includes a component of chance or randomization. Let’s get a taste for how this could work by creating our own algorithmic code maker.

Skills to be Obtained:

- Write C++ code that collects user input and creates output

- Generate random numbers and seed the random number generator

- Use branching in a program using somewhat complex logic

- Display messages, including messages with numeric values, to the screen

Please note: Before you begin writing code, make pseudocode to explain in plain English what your code should do. Use this to guide the writing of your code and include your pseudocode in your submission!

Overview:

Our program will create a brief sequence of letters, just 6 letters long. For simplicity, the letters will be only A, B, C, D, E, F, and G. The rules that determine each letter are listed below. Each of the six rules determines one letter in turn. The user will “create” the sequence by choosing a seed for the random number generator, and the computer does the rest. After seeding the random number generator with the user’s choice, the program should then generate 6 random integers between 1 and 200 (e.g., 20, 1, 18, 4, 13, 6; or 4, 8, 15, 16, 23, 42). Using these 6 numbers and the rules below, determine the letters in the sequence and output them.

Guide:
You will need to make the 6 random numbers first, so you will need variables to store the numbers and a variable to store the random number used to seed randomization. You will also need the use srand to ensure randomness using the number given by the user (check the slides if this does not make sense!).

To make the random numbers, use the rand function with the correct range using the % function and addition. Once you make these numbers, use the rules with the various types of if statements while outputting the letters as you go.

Rules to Determine Letter Outputs:

Letter 1:

a) If the 1st number is even, the first letter is C.

b) If the 1st number is odd, the first letter is E.

Letter 2:

a) If the 2nd number is greater than the 4th number, then the second letter is G.

b) If the 2nd number is less than or equal to the 4th number and is:

i. evenly divisible by 4, then the second letter is E.

ii. not evenly divisible by 4, then the second letter is C.

Letter 3:

a) If the 3rd number is less than 34, the third letter is C.

b) If the 3rd number is within the range 34 through 66 (inclusive), the third letter is B.

c) If the 3rd number is greater than 66, the third letter is E.

Letter 4:

a) If the 6th number is bigger than the 1st number AND the 6th number is bigger than the 2nd number, the fourth letter is A.

b) If the either condition listed above is not true, the fourth letter is F.

Letter 5:

a) If the sum of the 5th number and 6th number is greater than or equal to the sum of the 2nd number and the 4th number OR if the 4th number is greater than or equal to 120, the fifth letter is G.

b) Otherwise, the fifth letter is B.

Letter 6:

a) If the 6th number is less than 70, the sixth letter is the same as the first letter.

b) If the 6th number is within the range 70 through 140 (inclusive), the sixth letter is D.

c) If the 6th number is greater than 140, the sixth letter is G.

In this assignment, you will develop code that asks the user for an integer, uses that value as a random number generator seed, generates six random integers between 1 and 200, and then outputs to the screen the resulting 6-letter sequence created by the logic rules described above. When run, the only required output to the screen (after getting the user’s input) is the six letters indicating the letters, as in “C E B A G C”. If you wish, you can also output the six random integers—these may be useful in manually checking that the logic in the code is working correctly.

Extra Credit (Worth +3):

When you make the letters, make one string that contains a series of 6 words where one word is added to it after storing/outputting the letters. Then, at the end of the program, output the string composed of 6 words as a positive sentence or compliment. For example, the 6 words I might have stored were “You smart, awesome, and powerful hooman!”. For letter two, you might very the words between “smart”, “talented” and “fascinating” based on which letter you made, so the compliment is different every time. The words must not match just the letter, so if the third and fifth letter were both ‘B’, they would still have two different words. The hard part is making sure that each word is only used once in the program and that the final sentence always works! Please do not use any of the words I used in my example – be creative!! For those of you familiar with Parks and Recreation (TV), this is inspired by Leslie Knope’s very fun compliments. If you do this addition, still only submit one final code and report about the code in its final form.

Submission Requirements:

Please submit your work as a report by the due date listed on Canvas. Your report should introduce the problem, describe your solution using a brief overview in plain text and a more detailed description in pseudocode, prove your code’s effectiveness with a few example inputs and outputs (using, for example, screenshots or copy-paste text from the program window), and include the code in an Appendix. The code must be well-formatted, commented, and adhere to the general rubric (named ‘Rubrics’) on Canvas under Module - Reference. The pseudocode does not need to repeat all of the logic rules listed in this document—one line of the pseudocode could include something like “follow the given logic rules using the 6 random numbers.” Submit with your report all final code (.cpp) files you create as separate files. Please keep full report under 2 pages (Appendix does not count). We will use the general rubric on Canvas (under Assignments).

Checklist:

Please make sure your assignment contains the following items:

· Your code should

o Take an input from the user and output a 6 letter code

o Use the user input to make a 6 random numbers from 1-200

o Contain the logic rules listed above in proper, working order

o Contain comments to allow the grader to follow along with your code

· Your report should include:

o A problem overview and your solution (1 paragraph total)

o Pseudocode (bullet points)

o Screenshots of your code working

o Proper Formatting (check the Report Sample V1 on Canvas!)