Senior Division 1982
1.  VERTICAL HISTOGRAM
Write a program that reads text and prints a vertical histogram (bar 
graph) representing the occurrences of each letter of the alphabet (A-
Z) in the text.  Characters other than the letters (A-Z) are to be 
ignored.  You can assume that no lower case letters appear in the text.

Text to be tested:

"THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. 
THIS IS AN EXAMPLE OF HOW TO TEST YOUR HISTOGRAM 
PROGRAM.  YOU 
CAN USE THIS EXAMPLE."

Sample Run
              *
              *
    *         *
    *         *    *
*   *         *   **
*   *  *      *  ***
*   *  **   * *  ****
*   *  **   * ** ****
*   * ***  ***** ****  **
* * *****  ***** **** ***
**************************
ABCDEFGHIJKLMNOPQRSTUVWXYZ  



2.  FIFTEEN
Write a program that accepts a string of 5 digits (0 through 9) and 
prints out all possible combinations of these digits which add to 15. 
(The digit 0 counts as a 10 in computing the combinations.)  For 
example, with the input 50154, the output should display the following 
(perhaps in some other order):

5 0 1 5 4
- - - - - 
5 0
5   1 5 4
0 1     4
0       5

THERE ARE 4 COMBINATIONS TOTALING 15.



Test your program with each of the following inputs:  78787, 55555, 
06528.

Sample Run
ENTER A STRING OF 5 DIGITS: 78787

78787
-----
78
 87
7  8
  78
 8  7
   87

THERE ARE 6 COMBINATIONS TOTALING 15






3. AUTOMATED INFLATION
Write a program that will read any document and print out a new 
document where all the dollar amounts ($xx.xx) have been increased 
N% and where N is a number that is input by the user. Be sure to 
round off all numbers to two decimal places if necessary.  For 
example, $123.678 should be rounded up to $123.68.

Test your program for N=12% and 14% using the sample text :

BE ADVISED THAT ITEM #1234 COSTS $12.95 OR 2 FOR 
$25.00.REMIT TO P.O. BOX 2000.  MINIMUM ORDER IS $100.

Sample Run
ENTER % INCREASE: 12

BE ADVISED THAT ITEM #1234 COSTS $14.50 OR 2 FOR $28.00. 
REMIT TO P.O. BOX 2000.  MINIMUM ORDER IS $112.






4.  TENNIS SET
A tennis game between two players has the following rules:
1.  A point can be won by either player.
2.  A game is won when one player has won at least four points and 
leads 
     the opponent by at least two points.
3.  A set  is won when one player has won at least six games and leads 
by at least two games.

Simulate  playing tennis as follows:

Call the players  'A' and 'B'.  Enter the probability P (0_P_1) that A 
wins a given point.  Each game won by player A is indicated by 
printing the letter A.  If  B wins the letter B is printed.  The winner of 
the set is indicated by printing in brackets the letter corresponding to 
the winner followed by the score.  For example, a given set is 
summarized by the sequence below:
        ABBABAABAA     (A wins 6 - 4)

You are to display the results of N sets, where N is entered by the user.  
After displaying the results of the N sets, print the summary line:

 PLAYER A WON __ SETS OUT OF __.

Test your program with N=10, P=.55, and with N=10, P=.60.

Sample Run
NUMBER OF SETS: 10

PROBABILITY THAT 'A' WINS A POINT: .55

BAABBAAABA     ( A WINS 6 - 4 )
BABBAAABBABB   ( B WINS 7 - 5 )
BBAAAAAA       ( A WINS 6 - 2 ) 
BABABAABBB     ( B WINS 6 - 4 )
BAABAAABA      ( A WINS 6 - 3 )
AAAAABA        ( A WINS 6 - 1 )
AABABABABA     ( A WINS 6 - 4 )
BABAAABAA      ( A WINS 6 - 3 )
BBAAAAAA       ( A WINS 6 - 2 )
AABAAAA        ( A WINS 6 - 1 )

PLAYER 'A' WON 8 SETS OUT OF 10.

5.  FRACTIONS TO DECIMALS
Write a program that will accept a fraction of the form N/D where N is 
the numerator and D is the denominator and prints out the decimal 
representation. If the decimal representation has a  repeating 
sequences of digits this is to be indicated by enclosing them in 
brackets.  For example, 1/3 = .33333333...is denoted as .(3), and 
41/333 = .123123123...is denoted as .(123).

Typical conversions are:

1/3          =     .(3)
22/5        =     4.4
1/7          =     .(142857)
3/8          =     .375
45/56      =     .803(571428)

Test your program with the fractions above and the fraction 11/59.

Sample Run

ENTER N,D : 1,7

1/7 = .(142857)








                                     ICPSC 1982
                            Senior Division Problems





