Documente Academic
Documente Profesional
Documente Cultură
Problem 1:
Write a program that will:
o Accept alphanumeric string (maximum of 50 characters)
o Compute and display the summation of the all the numeric characters found in the given
string.
Sample output:
Input String: joy 2 the world 4 8 may make us happy
Output: 14 (from 2+4+8)
Problem 2:
Write a complete program that will correctly decode a set of characters into a valid message. Your
program should read a given file of a simple coded set of characters and print the exact message that
the characters contain. The code key for this simple coding is a one for one character substitution
based upon a single arithmetic manipulation of the printable portion of the ASCII character set.
1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5
Output:
Average Problems:
Problem 1:
Problem 2:
Write a program that plays the game Rock−Paper−Scissors with the user until the user does not want
to play any longer. In a single game the user makes a choice of rock, paper, or scissors and the
computer does also. The computer’s choice is made randomly. Rock beats scissors, scissors beats
paper, and paper beats rock.
Your program must have the following properties.
. When your program prompts the user about playing another game, your program must handle the
user entering an invalid value (that is, not yes or no) by detecting that the value is invalid and
repeating the prompt until a valid answer is given by the user.
. When your program prompts the user about making a choice of rock, paper, or scissors, your
program must handle the user entering an invalid value by detecting that the value is invalid and
repeating the prompt until a valid answer is given by the user.
. The computer’s choice must be generated randomly
. Your program output must look like the example output shown below (except that because the
computer’s choice is randomly generated, its choice may differ). User input is shown in italics and
program output is shown in boldface.
Difficult Problem:
Problem 1:
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make
changes with these coins for a given amount of money.
For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-cent
coin, two 5-cent coins and one 1-cent coin, one 5-cent coin and six 1-cent coins, or eleven 1-cent
coins. So there are four ways of making changes for 11 cents with the above coins. Note that we
count that there is one way of making change for zero cent.
Write a program to find the total number of different ways of making changes for any amount of
money in cents. Your program should be able to handle up to 7489 cents.
Input
The input consists of a number for the amount of money in cents.
Output
output a line containing the number of different ways of making changes with the above 5 types of
coins
Sample Input
11 --- (10-1, 1-1) (5-2, 1-1) (5-1, 1-6), (1-11)
Sample Output
4
Problem 2
Tags are keywords used in HTML and XML document. Normal tags contains start tag (ie <body>) and
end tag </body>. These are some of the examples of HTML tags:
Write a program to accept series of tags and validate if the tag is balance or un-balance tag. Balance
tag are tags wit start and end tag.
Sample 1
Enter series of tags:
<body> <head> <p> </p> <bold> </bold></head> </body>
Output
Balanced tag
Sample
Enter series of tags:
<body> <head> </p> <bold> </head> </body>
Output
Un-balanced tag