FLORIDA HIGH SCHOOLS COMPUTING COMPETITION '84
 
 
1.1  Write a program that will produce a table of values in 
Fahrenheit degrees for given CELSIUS degrees.  Have the Celsius 
table start at 50 and be incremented by 25 stopping at 200.  The 
output should show a two column table with headings CELSIUS on the 
left and FAHRENHEIT on the right.  The values in degrees 
FAHRENHEIT should be rounded off to the nearest whole number.  
(The formula to be used is F = 1.8 C + 32) 
 
 
1.2  Write a program that will compute how long a person sleeps at 
night in seconds.  Assume that the person goes to bed between noon 
and midnight and gets up between midnight and noon.  The computer 
should ask you to enter the time when you go to bed and the time 
when you wake up (hours, minutes, and seconds) as follows: 
 
     WHAT TIME DID YOU GO TO BED (H, M, S)? 
     WHAT TIME DID YOU GET UP (H, M, S)? 
and then compute: 
     YOU SLEPT FOR XXXXX SECONDS. 
 
 
1.3  A golfer hits a golf ball in such a way that the horizontal 
distance from the point of contact to the ball in feet is given by 
the equation h = 120t, where t is the time in seconds since the 
ball is hit.  The height of the ball above the ground is given by 
v = 120t - 16t^2.  Write a program to produce a three column 
table, with headings, giving the values of t, h, and v at 1/2 
second intervals for values up to the point that the ball returns 
to the ground.  The values of v should be rounded off to the 
nearest whole number. 
 
 
1.4  A colony of mice is placed in a closed environment.  At the 
beginning of the experiment there are 10 mice and food supply for 
100.  Each year the population of mice doubles while the food 
supply increases only enough to feed 40 more mice.  Write a 
program to print a table of data in the following form: 
 
     NUMBER OF YEARS    POPULATION    FOOD SUPPLY FOR 
 
     0                  10            100 
     1                  20            140 
     .                  .             . 
     .                  .             . 
     .                  .             . 
 
The printing of the table should stop when the population outgrows 
the food supply. 
 


1.5  Write a program to determine how long, in years, it will take 
for a savings account to double in value if it is compounded 
annually.  The initial amount of the account as well as the annual 
interest rate in percent can be entered through input statements. 
 
 
1.6  Write a program that allows the user to input five first 
names and then prints (a) the name that is alphabetically closest 
to the beginning of the alphabet, and (b) closest to the end of 
the alphabet. 
 
 
1.7  Write a program to simulate tossing a coin N times and 
determine the longest run of heads.  The program should allow the 
user to input N, and computer should then print the greatest 
number of consecutive heads. 
 
 
1.8  Write a program in which the computer prints the numbers from 
1 100, but for any number containing the digit 7, it displays ZAP 
instead of displaying the number.  For a number that contains a 7 
and is also divisible by 7 the display should be ZAPZAP. 
 
 
1.9  Write a program that allows the user to input text for which 
the computer then prints the number of double letters, i.e. the 
number of times that a character is the same as the one before it. 
 
 
1.10  Write a program to assist third-graders with their sevens 
multiplication facts.  In particular, a student should be asked to 
answer the questions: 
                      0 X 7 = ? 
                      1 X 7 = ? 
                      . 
                      . 
                      9 X 7 = ? 
 
If a question is answered correctly, the next question should be 
asked; if not, the question should be repeated.  However, if the 
same question is answered incorrectly twice, the correct answer 
should be printed and then the next question should be asked.



2.1  Write a program that allows the user to input text for which 
the computer then prints the total number of vowels that it 
contains. 
 
 
2.2  A rational number is the quotient of two integers N/M 
(M<>0).  Write a program that will sort a given sequence of 
rational numbers and print them out in increasing order.  The 
program should allow the user to input each rational number as a 
pair of integers (e.g., 3/4 will be input as 3,4).  However, the 
output should be in the form N/M.  The user should be able to 
terminate the input by entering 0,0.  Assume the numerators and 
the denominators do not exceed 99 and no more than 99 rational 
numbers will be input. 
 
 
2.3  The number 153 has an interesting property.  It equals the 
sum of the cubes of its digits, that is, 153=1^3 + 5^3 + 3^3.  
There are only four three-digit numbers (including 153) with this 
property.  Write a program that will generate these four numbers. 
 
 
2.4  The triangle listed below is generated by following a certain 
algorithm.  Write a program that will generate similar triangles 
for any number of rows < 20.  The program should allow the user to 
input the number of rows. 
 
                               1 
                              232 
                             34543 
                            4567654 
                           567898765 
                          67890109876 
                         7890123210987 
 


2.5  Write a program which generates a page of multiplication 
exercised similar to those shown below.  The program should 
generate 6 exercises with the factors randomly chosen, and the 
output should be in the format shown. 
               MULTIPLICATION DRILL 
 
    1.  53                             4.  12 
       X 4                                X 3 
       ----                               ---- 
 
    2.  36                             5.  94 
       X 1                                X 8 
       ----                               ---- 
 
    3.  72                             6.  39 
       X 6                                X 5 
       ----                               ---- 
 
 
2.6  Write a program that simulates throwing darts at a 5 by 5 
square checkerboard.  Each throw will hit randomly in any of the 
25 possible squares with equal likelihood.  N darts are thrown at 
the board, with N an input value.  The results and squares hit are 
displayed on the screen as below: 
 
                      .  .  .  .  . 
                      .  .  *  .  * 
                      *  *  .  .  . 
                      .  .  .  *  . 
                      .  .  *  .  . 
 
                      NUMBER OF THROWS = 9 
                      NUMBER OF SQUARES HIT = 6 
 
In this example an "*" in a position indicates that a square has 
been hit (at least once), and a "." means the square has not been 
hit. 
 
 
2.7  Write a program that allows the user to input a text and then 
tells the user whether or not it is a palindrome.  A palindrome is 
a statement that reads the same forward or backward after all non-
alphabetic characters have been removed. 
 
Example:  DOOM AN EVIL DEED, LIVEN A MOOD 
 


2.8  Write a program that will allow a sentence to be input and 
then print a letter frequency table which will list the frequency 
and percentage of occurrences of each letter (A through Z) of the 
text in alphabetical order.  The table should be headed with the 
line 
     LETTER                FREQUENCY                 PERCENT 
 
and should have a final line 
 
     TOTAL                   XXX 
 
Where XXX is the total number of letters in the sentence.  Letters 
which do not occur in the text should not be listed.  Percents 
should be rounded to the nearest whole percent. 
 
 
2.9  Write a program that asks the user to type in a sentence and 
then it prints the longest word in the sentence.  Assume that the 
user always types in a sentence that has one word longer than any 
of the others. 
 
 
2.10  The children's game of Rock, Scissors, and Paper is played 
by two opponents.  At each turn both players simultaneously signal 
their choices of either Rock, Scissors, or Paper.  The winner of 
that turn is determined by the rule that Rock wins over Scissors, 
Paper wins over Rock, and Scissors wins over Paper.  If both 
choices are the same, it is a tie.  Write a program to play a game 
of Rock, Scissors, Paper between the computer and yourself.  At 
each turn, the computer randomly chooses either Rock, Scissors or 
Paper (without letting you know).  It then prompts you for your 
choice.  You enter R for Rock, S for Scissors, or P for Paper.  
The program then prints the winner of that turn.  The game 
continues until you enter a Q to quit when it is your turn.  The 
program should print a summary of the game's results.
 



3.1  Write a program that will begin by displaying an S in the 
approximate center of the screen.  A randomly determined trail of 
asterisks (*) should then be produced from that point, with the 
trail continuing until it either leaves the screen or intercepts 
itself.  At this point the trail should stop and the maximum 
distance that the asterisk has reached from the starting point 
should be printed.  The maximum distance should be the straight 
lines distance between two points.  Upon hitting any key, the 
program should rerun. 
 
SAMPLE OUTPUT: 
                        S**** 
                        * 
                        * 
                        * 
      THE MAXIMUM DISTANCE FROM START IS 5.
 
 
3.2  Computers are often used in code breaking.  In the English 
language the twelve most frequently used letters are 
ETAOINSHRDLU.  Write a program that will automatically substitute 
the letter E for the most frequent character in a coded message, 
the letter T for the second most frequent character, and so on.You 
may assume that no two characters occur with the same frequency 
and that no blanks or punctuation occurs.  Limit the message to 32 
characters. 
 
SAMPLE RUN: 
             MESSAGE?  ABBRBRXXXX 
             THE DECODED MESSAGE IS OTTATAEEEE 
 
 
3.3  The digital product of a positive number N is defined as the 
product of its non-zero digits.  For example, the digital product 
of the number, 1239, is 54.  In turn, the digital product of 54 is 
20, and the digital product of 20 is 2.  This number 2 is called 
the digital product root of 1239.  The digital product root of 
number is always a single digit number determined in this 
fashion.  Write a program that requests an input of a number from 
one to seven digits long and then prints the number followed by 
the sequence of repeated digital products ending with the digital 
product root. 
 
SAMPLE RUN: 
             ORIGINAL VALUE (1 TO 7 DIGITS) ? 9999090 
             9999090 
             59049 
             1620 
             12 
             2 



3.4  A positive integer N>1 is called a prime number if its only 
positive factors are 1 and N.  If N and N+2 are both primes, then 
the two numbers are called "twin primes".  Write a program that 
will request an upper search limit and then display all twin prime 
pairs not greater than the number set as the upper limit. 
 
SAMPLE RUN: 
             N= 20
             TWIN PRIME PAIRS NOT GREATER THAN 20 
 
             3     5 
             5     7 
             11    13 
             17    19 
 
 
3.5  There are n people (n<=26) whose names are A,B,C,... and a 
phone booth with a capacity m (m<=n).  Assume that a subset of m 
people is to be selected from the set of n people to fill the 
booth.  Write a program to list all possible subsets of m people.  
The program should allow the user to input n and m.  The output 
should list the subsets of names and state the number of subsets. 
 
SAMPLE RUN: 
             INPUT NUMBER, CAPACITY? 5,3 
 
             ABC ABD ABE ACD ACE 
             ADE BCD BCE BDE CDE 
 
             THERE ARE 10 SUBSETS 
 
 
3.6  Write a program to read from DATA statements a collection of 
strings, and to print a vertical histogram (bar graph) 
representing the occurrences of each letter of the alphabet (A-Z) 
in the strings.  Assume that the string *END* terminates the 
data.  Characters other than letters are to be ignored.  The data 
will contain no lower case letters. 
 
SAMPLE OUTPUT SHOULD LOOK LIKE: 
 
*   *     * 
*  **  *  *     * 
*  **  *  *  *  *  * 
ABCDEFGHIJKLMNOPQRSTUVWXYZ 



3.7  Write a program that will allow the user to input the 
numerator and denominator of a fraction (N/D) where both numbers 
are integers 1 to 256.  The program should then print the decimal 
representation indicating those decimals with repeating sequences 
by enclosing them in parentheses.  For example the repeating 
decimal, .134134134... should be reported as .(134). 
 
SAMPLE OUTPUT: 
               1/3 = .(3) 
               22/5 = 4.4 
               3/8 = .375 
 
 
3.8  A positive integer, N, is said to be a "round" number if, 
when the number is expressed in binary, there is an equal number 
of 1's and 0's.  The number 9 is a round number 26 is not round 
since its binary representation is 11010.  Write a program that, 
when a positive integer is input, will output the number of round 
numbers that are less than or equal to the input number. 
 
SAMPLE RUN: 
             INPUT NUMBER?  10 
             THERE ARE 3 ROUND NUMBERS LESS THAN OR EQUAL TO 10 
 
 
3.9  Write a program that will read a series of DATA statements 
dealing with prices and then will automatically update the money 
amounts to reflect an input rate of price increase.  All money 
amounts should be rounded to the nearest cent.  You will be given 
a set of DATA lines to run as well as an increase in cost 
expressed as percent.  Assume that the DATA statements will be 
terminated with *END*. 
 
EXAMPLE: 
          Assume that your DATA lines are: 
 
          DATA "THE CURRENT COST OF BUCKLES IS" 
          DATA "3 FOR $2.50, OR $10.00 A DOZEN." 
          DATA "*END*" 
 
          If you input a value of 10% for the price increase, the
          line would be printed out as: 
 
          THE CURRENT COST OF BUCKLES IS 
          3 FOR $2.75, OR $11.00 A DOZEN. 



3.10  A tennis set between two players has the following rules: 
 
      1. A point can be won by either player. 
      2. A game is won when a player has won at least 4 points
         and leads the other player by at least 2 points. 
      3. A set is won when a player has won at least 6 games 
         and leads by at least 2 games. 
 
Write a program that simulates playing several sets of tennis. The 
two players are designated A and B.  The user should be asked to 
input the number of sets and the probability that player A will 
win a point.  The letter designating the winner of a point is to 
be printed.  At the end of each game the name of the winning 
player is printed enclosed in parentheses, (A) or (B).  At the end 
of the set, the name of the winner is printed along with the 
number of wins. 
 
SAMPLE OUTPUT: 
 
               NUMBER OF SETS = 10 
               % CHANCE A WINS A POINT=60 
 
               AABAAAA (A) 
               BAAAAABA (A) 
               AAAABABA (A) 
               AABABAABA (A) 
               BABBBAABB (B) 
               AAABABAA (A) 
               ABAAABAA (A) 
               ABAABAAA (A) 
               AAAAAA (A) 
               AAAABAA (A) 
 
               PLAYER 'A' WON 9 SETS OUT OF 10