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 »
Please view the file attached below on how to work


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 (array index #14) to first random number (array 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 current random number. The use of a single integer array of size 15 is required. Example Execution #1: Enter seed value -> 1000 Index: 13 Value - 801148 Max Square - 4 Index: 11 Value - 257284 Max Square - 4 Index: 9 Value - 9856 Max Square - 64 Index: 6 Value - 871804 Max Square - 4 Index: 1 Value - 770780 Max 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 - 60885 Max Square - 9 Index: 13 Value - 268444 Max Square - 4 Index: 12 Value - 564725 Max Square - 1225 Index: 9 Value - 119169 Max Square - 9 Index: 8 Value - 240056 Max Square - 4 Index: 6 Value - 722824 Max Square - 4 Index: 5 Value - 226444 Max Square - 4 Index: 2 Value - 841059 Max Square - 9 Index: 1 Value - 699204 Max Square - 4 Index: 0 Value - 363950 Max 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 - 58671 Max Square - 9 Index: 9 Value - 485757 Max Square - 81 Index: 8 Value - 349236 Max Square - 36 Index: 6 Value - 392164 Max Square - 4 Index: 5 Value - 199548 Max Square - 36 Index: 4 Value - 278901 Max Square - 9 Index: 2 Value - 754803 Max Square - 9 Index: 1 Value - 790650 Max Square - 225 Index: 0 Value - 545994 Max 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 - 576000 Max Square - 57600 Index: 9 Value - 731025 Max Square - 81225 Index: 7 Value - 835499 Max Square - 14161 Index: 6 Value - 809172 Max Square - 6084 Index: 4 Value - 116162 Max Square - 58081 Index: 0 Value - 689040 Max Square - 144 Academic Integrity Reminder: Please review the policies of the course as they relate 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 - 333032 Max Square - 4 Example Execution #7: Enter seed value -> 0 Error! Seed must be a positive integer value!! Enter seed value -> -1 Error! Seed must be a positive integer value!! Enter seed value -> 3183696 Index: 14 Value - 279333 Max Square - 9 Index: 13 Value - 798741 Max Square - 81 Index: 12 Value - 339228 Max Square - 324 Index: 11 Value - 696672 Max Square - 144 Index: 10 Value - 629192 Max Square - 4 Index: 9 Value - 769916 Max Square - 4 Index: 8 Value - 272178 Max Square - 9 Index: 7 Value - 188448 Max Square - 16 Index: 6 Value - 410260 Max Square - 4 Index: 5 Value - 339832 Max Square - 4 Index: 4 Value - 255021 Max Square - 169 Index: 3 Value - 40420 Max Square - 4 Index: 2 Value - 332682 Max Square - 7921 Index: 1 Value - 474544 Max Square - 16 Index: 0 Value - 57216 Max 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 be 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 array structures (chapters 9 and 10) would violate this requirement and result in no credit being awarded for your effort. See course standards below for array 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 array is known prior to the start of a program. • The course standards expect all arrays to be of a fixed size. Variable-size arrays, 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 74-75) in 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 correct file to the correct 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 AfterNov 13, 2021

Answer To: CS 159 – HW #06 Due: Monday, November 15, 2021 at 11:00pm (time local to West Lafayette, IN). 10...

Sathishkumar answered on Jan 06 2022
123 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