Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CS 159 – HW #06 Due: Monday, November 15, 2021 at 11:00pm (time local to West Lafayette, IN). 10 Points Possible Problem: Given a positive integer to serve as the seed value for the random number...

1 answer below »
CS 159 – HW #06
Due: Monday, November 15, 2021 at 11:00pm (time local to West Lafayette, IN).
10 Points Possible
Problem: Given a positive integer to serve as the seed value for the random number generator, generate 15 random
numbers between 1 and 1,000,000 inclusive and display in reverse order (from last random number (a
ay index #14) to
first random number (a
ay index #0)) the largest perfect square greater than one (22 = 4, 32 = 9, 42 = 16, 52 = 25, 62 = 36
and so on) that is a divisor of the cu
ent random number. The use of a single integer a
ay of size 15 is required.
Example Execution #1:
Enter seed value -> 1000
Index: 13 Value XXXXXXXXXXMax Square - 4
Index: 11 Value XXXXXXXXXXMax Square - 4
Index: 9 Value XXXXXXXXXXMax Square - 64
Index: 6 Value XXXXXXXXXXMax Square - 4
Index: 1 Value XXXXXXXXXXMax Square - 4
Note on First Example Execution:
The tenth value generated (index 9) was 9856 and
this number has 4, 16, and 64 as divisors that are
also perfect squares.
Example Execution #2:
Enter seed value -> 20019
Index: 14 Value XXXXXXXXXXMax Square - 9
Index: 13 Value XXXXXXXXXXMax Square - 4
Index: 12 Value XXXXXXXXXXMax Square - 1225
Index: 9 Value XXXXXXXXXXMax Square - 9
Index: 8 Value XXXXXXXXXXMax Square - 4
Index: 6 Value XXXXXXXXXXMax Square - 4
Index: 5 Value XXXXXXXXXXMax Square - 4
Index: 2 Value XXXXXXXXXXMax Square - 9
Index: 1 Value XXXXXXXXXXMax Square - 4
Index: 0 Value XXXXXXXXXXMax Square - 25
Note on Second Example Execution:
The thirteenth value generated (index 12) was
564725 and this number has 25, 49, and 1225 as
divisors that are also perfect squares.
Example Execution #3:
Enter seed value -> 179
Index: 11 Value XXXXXXXXXXMax Square - 9
Index: 9 Value XXXXXXXXXXMax Square - 81
Index: 8 Value XXXXXXXXXXMax Square - 36
Index: 6 Value XXXXXXXXXXMax Square - 4
Index: 5 Value XXXXXXXXXXMax Square - 36
Index: 4 Value XXXXXXXXXXMax Square - 9
Index: 2 Value XXXXXXXXXXMax Square - 9
Index: 1 Value XXXXXXXXXXMax Square - 225
Index: 0 Value XXXXXXXXXXMax Square - 9
Note on Third Example Execution:
Several values generated have multiple divisors
that are perfect squares greater than one including;
485757 [9, 81], 349236 [4, 9, 36], 199548 [4, 9,
36], and 790650 [9, 25, 225].
Example Execution #4:
Enter seed value -> 10070
Note: Data set contains no values with a max square divisor greater than one.
Example Execution #5:
Enter seed value -> 331306
Index: 14 Value XXXXXXXXXXMax Square XXXXXXXXXX
Index: 9 Value XXXXXXXXXXMax Square XXXXXXXXXX
Index: 7 Value XXXXXXXXXXMax Square XXXXXXXXXX
Index: 6 Value XXXXXXXXXXMax Square - 6084
Index: 4 Value XXXXXXXXXXMax Square XXXXXXXXXX
Index: 0 Value XXXXXXXXXXMax Square - 144
Academic Integrity Reminder:
Please review the policies of the course as they
elate to academic integrity. The assignment you
submit should be your own original work. You are
to be consulting only course staff regarding your
specific algorithm for assistance. Collaboration is
not permitted on individual homework
assignments.
Example Execution #6:
Enter seed value -> 5423
Index: 0 Value XXXXXXXXXXMax Square - 4
Example Execution #7:
Enter seed value -> 0
E
or! Seed must be a positive integer value!!
Enter seed value -> -1
E
or! Seed must be a positive integer value!!
Enter seed value -> XXXXXXXXXX
Index: 14 Value XXXXXXXXXXMax Square - 9
Index: 13 Value XXXXXXXXXXMax Square - 81
Index: 12 Value XXXXXXXXXXMax Square - 324
Index: 11 Value XXXXXXXXXXMax Square - 144
Index: 10 Value XXXXXXXXXXMax Square - 4
Index: 9 Value XXXXXXXXXXMax Square - 4
Index: 8 Value XXXXXXXXXXMax Square - 9
Index: 7 Value XXXXXXXXXXMax Square - 16
Index: 6 Value XXXXXXXXXXMax Square - 4
Index: 5 Value XXXXXXXXXXMax Square - 4
Index: 4 Value XXXXXXXXXXMax Square - 169
Index: 3 Value XXXXXXXXXXMax Square - 4
Index: 2 Value XXXXXXXXXXMax Square - 7921
Index: 1 Value XXXXXXXXXXMax Square - 16
Index: 0 Value XXXXXXXXXXMax Square – 64
Additional Requirements:
1. Add the homework assignment header file to the top of your program. A description of your program will need to
e included in the assignment header.
2. Each of the example executions provided for your reference represents a single execution of the program.
Your program must accept input and produce output exactly as demonstrated in the example executions. Your
program will be tested with the data seen in the example executions and an unknown number of additional tests
making use of meaningful data. The only input validation requirement in this problem is demonstrated in the final
example execution.
3. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to
follow course standards as they relate to good user-defined function use will result in a zero for this assignment.
4. Revisit course standards as it relates what makes for good use of user-defined functions, what is acceptable
to retain in the main function, and when passing parameters by address is appropriate. In many cases user-
defined function use should result in a main function that only declares variables and makes function calls.
5. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment you
may consider all material in the first eight chapters of the book, notes, and lectures to be acceptable for use.
◦ The use of any dynamic a
ay structures (chapters 9 and 10) would violate this requirement and result in no
credit being awarded for your effort. See course standards below for a
ay declaration expectations.
6. A program MUST compile, be submitted through Vocareum and submitted prior to the posted due date to be
considered for credit. The C-file you submit must be named exactly: hw06.c, no variation is permitted.
Course Programming and Documentation Standards Reminders:
• It is common to make use of a symbolic/defined constant when the size of the a
ay is known prior to the start of a
program.
• The course standards expect all a
ays to be of a fixed size. Variable-size a
ays, even those demonstrated in
chapter 8 of the text, would violate course standards.
• Code found inside the body of relevant selection and repetition constructs must be indented two additional spaces.
• Make use of { and } with all relevant selection and repetition constructs.
• See page 258 of your C programming text regarding the proper indentation for a switch construct.
• Use the course function header (head_fx vi shortcut hfx while in command mode) for every user-defined
function in your program.
◦ List and comment all parameters to a function, one per line, in the course function header.
◦ All function declarations will appear in the global declaration section of your program.
◦ The user-defined function definitions will appear in your program after the main function.
• Maximize your use of symbolic/defined constants and minimize your use of literal constants.
• Indent all code found within the main function exactly two spaces.
• Place a single space between all operators and operands.
• Comment all variables to the right of each declaration. Declare only one variable per line.
• Notice that several programs (see program 2-9 on pages XXXXXXXXXXin the programming text use a single line
comment to indicate the start of the local declaration and executable statement sections of the main function.
◦ At no point during the semester should these two sections ever overlap.
• Select meaningful identifiers (names) for all variables in your program.
When you submit... only the final successful submission is kept for grading. All other submissions are over-written and
cannot be recovered. You may make multiple submissions but only the last attempt is retained and graded.
• Verify in the confirmation e-mail sent to you by the course that you have submitted the co
ect file to the co
ect
assignment.
• Leave time prior to the due date to seek assistance should you experience difficulties completing or submitting
this assignment. All attempts to submit via a method other than through the appropriate assignment on Vocareum
will be denied consideration.
Assignment deadlines... are firm and the electronic submission will disable promptly as advertised. We can only grade
what you are able submit via Vocareum prior to the assignment deadline.
Answered 66 days After Nov 13, 2021

Solution

Sathishkumar answered on Jan 06 2022
126 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here