# Sample Questions from the 2012 Contest

## Problem Description

The most common form of Universal Product Code (UPC) is UPC-A which has 12 digits arranged to make a unique number. The twelfth digit is a check digit calculated based on the values in digits one through eleven. Calculate a UPC-A check digit given the eleven digits.

## Detail Requirements

- Read eleven single digit numbers. You must enter these as one complete “number” and not as individual digits or characters. This means you must enter the digits and press the enter key once to have your application read the entire “number” if you are using a console application. You cannot enter each digit individually and click a button to process it if you are using a graphical user interface. Enter all the digits and then click the process button once.
- Only numbers will be entered as test data. No letters, spaces, or special characters will be entered.
- To calculate the check digit:
- Add the digits in the odd numbered positions (first, third, fifth, …).
- Multiply the above sum by three.
- Add the digits in the even numbered positions (second, fourth, sixth, …) to the total from above.
- Find the remainder when you divide the result by ten.
- The check digit is zero if the remainder is zero. Otherwise subtract the remainder from ten to get the check digit.

- Display the original “number” and the check digit.
- Add comments at the top of your source code for your name and the problem number.
- The judges will enter additional data not provided above to further test your application. Only valid numbers will be entered as test data. Each set of test data can be tested by rerunning the application.
- A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
Enter the UPC code minus the check digit: 01600027559

Check digit for 01600027559 is 1 - A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
## Test Data

Input Output 01600027559 Check digit for 01600027559 is 1 74953850500 Check digit for 74953850500 is 6 40010068896 Check digit for 40010068896 is 0

## Problem Description

A numeric sequence is a series of numbers in which the relation of a number to the one that follows it is the same. For example, 1, 2, 3, 4 and 3, 6, 12, 24 are both sequences. In the first sequence each number is one less than the one that follows it. In the second sequence, each number is one-half the one that follows it. Two types of numerical sequences are arithmetic and geometric. The first sequence is arithmetic because each number differs from its predecessor by the same value - in this case 1. The second sequence is geometric because each number differs from its predecessor by the same multiplication factor - in this case 2.

The term for a sequence is the value at any given location. Given the sequence 3, 6, 12, 24, the first term is 3, the third term is 12, and the fifth term would be 48.

Determine whether a list of numbers is a sequence (arithmetic or geometric) and the type. Determine the value of the Nth term if the list is a sequence.

## Detail Requirements

- Prompt the user to enter a maximum of 10 numbers. The user can signify the end of data entry before 10 numbers by entering 99999. Display an error and end the application if fewer than three numbers are entered.
- Prompt the user to enter an integer number (N) for the Nth term in the sequence.
- Determine if the list of numbers entered is an arithmetic sequence, a geometric sequence, or neither. Print one of the following:
- The list is an arithmetic sequence.
- The list is a geometric sequence.
- The list is not a sequence.

- Display the value of the Nth term if the list is a sequence.
- Add comments at the top of your source code for your name and the problem number.
- The judges will enter additional data not provided above to further test your application. Only integer numbers will be entered as test data. No letters, spaces, or special characters will be entered. Each set of test data can be tested by rerunning the application.
- A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
Enter up to 10 numbers:

Number 1: 7

Number 2: 9

Number 3: 11

Number 4: 13

Number 5: 15

Number 6: 99999

Enter N for the ninth term: 27

The list is a(n) arithmetic sequence - A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Problem Description

A series of right triangles can be inscribed (nested) within each other as shown in the figure below. The original right triangle has three smaller triangles nested inside. The area of each nested triangle obviously decreases as it gets smaller. The goal is to determine the area of the right triangle nested at a specific level.

The area of a right triangle is ½ (base * height). The height for a right triangle is the line perpendicular to the base. In the outer triangle above, the base is b and the height is a. The sides of each nested triangle are ½ the length of its parent triangle. For example, if a = 30, b = 40, and c = 50 then the equivalent sides for the first nested triangle are 15, 20, and 25 respectively. You are given a set of three (x,y) coordinates for an outer triangle. You are also given the number of nested triangles. Use this information to determine the area of the triangle at that level.

A Cartesian coordinate system is used as displayed below. The 3 (x,y) coordinates for the given right triangle are (-7,5), (-7,-5), and (5,-5).

- Accept three sets of x,y coordinates representing the points of a right triangle.
- The coordinates are guaranteed to form a right triangle when lines are drawn between them. The coordinate pairs must be entered one number at a time. See the sample user interface below.
- The base of the triangle is always parallel to either the X or Y axis.
- Accept a number representing how many levels of nesting must occur.
- Display the area of the right triangle at that level.
- Add comments at the top of your source code for your name and the problem number.
- The judges will enter additional data not provided above to further test your application. Only integer numbers will be entered as test data. No letters, spaces, or special characters will be entered. Each set of test data can be tested by rerunning the application.
- A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
Enter x1:5

Enter y1:5

Enter x2:45

Enter y2:5

Enter x3:5

Enter y3:35

Enter how many nested triangles doyou want: 3

The areofnested triangle 3 is 9.375 - A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

Foreign Language

## Problem Description

Derwin is trying to convince his teacher that Pig Latin is an appropriate foreign language. He says he speaks and writes Pig Latin fluently. He also informs his professor that none other than Thomas Jefferson used to write his friends in Pig Latin. Derwin’s professor, always a good sport, plans to translate all Derwin’s assignments for the rest of the semester into Pig Latin but needs help. You will help by writing an English to Pig Latin translation program.

## Detail Requirements

- Read a sentence from the console. The sentence will end with the “word” zzzzz. The zzzzz is a marker indicating the end of the input. Do not translate it to Pig Latin.
- Replace each English word with its Pig Latin equivalent. There are two basic rules.
- Add “way” to the word if it starts with a vowel (a, e, i, o, u). The English word “each” becomes the Pig Latin word "eachway".
- If the word doesn’t start with a vowel, take all the consonants from the beginning of the word up to (but not including) the first vowel. Move these to the end of the word. Add "ay". The English word "brick" becomes the Pig Latin word "ickbray".

- Keep the u with the q in words with the "qu" combination. The English word "quit" becomes the Pig Latin word itquay. We will ignore the few English words that have a q but no following u. Also you can assume that the qu combination will always be followed by a vowel. There will never be more than one letter q in a word.
- The letter y is normally considered a consonant except when there are no vowels in the word like "try". Treat the y as a vowel in this case and follow the rules of 2b. The English word "try" would become the Pig Latin word "ytray".
- Maintain the proper case of the word. The Pig Latin word must be uppercase if the English word begins with an uppercase letter. The English word Floridian would be Oridianflay. The phrase:

Go to School John.zzzzz

Would translate as:

Ogay otay oolschay ohnjay Notice the capitalization of the Ogay and Ohnjay. - Punctuation marks will only occur at the end of words and must be reproduced at the end of the respective Pig Latin word. The phrase:

John, it is time to leave! zzzzz

Would translate as:

Ohnjay, itway isway imetay otay eavelay! - Add comments at the top of your source code for your name and the problem number.
- The judges will enter additional data not provided above to further test your application. Only letters, spaces and punctuation will be entered as test data. A single space will separate each word. Each set of test data can be tested by rerunning the application.
- A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Test Data

Input 1

Derwin, here is your assignment for this week. Make sure you try all the problems! zzzzz

Output 1

Erwinday, erehay isway ouryay assignmentway orfay isthay eekway. Akemay uresay ouyay ytray allway ethay oblemspray!

Input 2

The assignment is not hard but you must start early. Do not delay. The quiz is Thursday. zzzzz

Output 2

Ethay assignmentway isway otnay ardhay utbay ouyay ustmay artstay earlyway. Oday otnay elayday. Ethay izquay isway Ursdaythay.