exam_FINAL_DIC_2015_EN_SOLUTION.pdf

# exam_FINAL_DIC_2015_EN_SOLUTION.pdf - Fundamentals of...

• Test Prep
• 10

This preview shows 1 out of 3 pages.

Fundamentals of Computer Science 1º GITI, GITT, IEM, ITL Dec/2015 1 First Name: Last name: Group: FI_1 FI_3 FI_GITT_ENG Duration: 1h 30min ANSWER THE EXAM IN THE BOOKLET FOR ANSWERS Program 1 (3 points) A program in C pretends to select numbers that have the possibility of winning in a lottery game. The idea is to search for numbers that if divided in two unequal parts, generate values that have a golden proportion (see below the information about golden numbers ). To find parts of the original number we must make sure that the sum of both parts has to be equal to the original number itself . To play the lottery game the player has to select 6 integer numbers. You must validate every number to make sure they don´t have more than 3 digits . Every time the player selects a number the program will indicate whether the number selected is a winner value (generates portions with golden propor- tion) or not. If the number selected does not have parts to provide golden proportion, the player has to repeat the selected number. The operation of selecting numbers continues until the player finds 6 val- id numbers necessary to play the game. To write the program you must follow these steps: 1) The player types an integer number that has no more than 3 digits (validate the number). 2) Call the function Golden() . This function receives the original number that the player wants to check to see if it provides the golden proportion. The function gives back by reference two num- bers with golden proportion or gives back two values equal to -1 if the they don´t produce a gold- en proportion, indicating that the original number is not valid as a winner number. 3) If a number selected is not valid as a winner, the user has to repeat the process and type another number. 4) If the original number typed is valid, the main program displays the original number and both parts of the number that produce the golden proportion (see the example). 5) The program continues until all 6 numbers valid for the game are selected. Note-1 : Numbers with golden proportion. Two numbers a y b with Golden Proportion obey the following rule: Considering a as the larger value and b as the smaller value, this expression produces a second degree equation and gives as a result the number PHI (the Golden number), with an approxi- mate value 1.618033. Note-2: In calculations we can use the division a/b to validate the Golden Proportion. In this program, to better approximate the divisions we use a constant PHI with a value equal to 1.6 . Additionally, because the value of division of a/b in many cases does not generate the exact value of PHI it is necessary to consider an error value . In this program we have to declare another constant ERROR with a value of 0.026. Additional Help : In order to find out if two portions of a number have golden proportion we must divide the original number in two unequal parts and check to see if those parts provide a golden pro-

Subscribe to view the full document.

Fundamentals of Computer Science 1º GITI, GITT, IEM, ITL Dec/2015 2 portion as indicated in Note-2 (the division of
You've reached the end of this preview.
• Fall '16
• Golden ratio, ITL

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern