1) Word guess
Let users choose a number between 0 and 4. The following array provides a word to be guessed according to the chosen number. @numbers=("chocolate", "strawberry", "pineapple", "marshmallow", "pistachio"). Split the chosen word into an array. Print as many "-" to the screen as the word has characters, for example, "----------" if the number was 1. Let the user then guess two characters. If the user guesses a character that is contained in the word, replace the "-" by the characters. In the example, if the user guesses "o" and "a", print "---a------". Next let the user guess the full word. If the user guesses the full word correctly print "Congratulations"; otherwise print "That's not it". Ask the user, if he/she wants to guess another word. If "yes" repeat the whole process starting from 'Let the user choose a number between 0 and 4'.
2) Database calculations
Write a script that reads a file called "input.txt" which is in the following format:
John Smith|A|A-|B+ Mary Miller|B+|A|A-Each line contains a student name (first name and last name) and three grades. The fields are delimited by the pipe symbol. To calcluate the final grade for each student, the letter grades need to be converted into numeric values as follows (there are no grades below B-). Use substitution for the conversion.
A 4.0 A- 3.7 B+ 3.3 B 3.0 B- 2.7Then the average of the three grades is calculated. The resulting number is comverted back into a letter grade as follows. (You can use if statements to do this.)
A 3.85 - 4.00 A- 3.5 - 3.85 B+ 3.15 - 3.5 B 2.85 - 3.15 B- 2.5 - 2.85The script then prints the students and their grades to the screen in the following format:
Smith, John: A- Miller, Mary: A-
3) Parsing mark up text
Example of XML:
<recipe>
<title>Two-Minute Fudge</title>
<ingredient-list>
<ingredient> 1 pound sugar </ingredient>
<ingredient> 1/2 cup butter </ingredient>
<ingredient> 1/4 cup milk </ingredient>
<ingredient> 1 tablespoon vanilla </ingredient>
<ingredient> 1 cup chopped nuts </ingredient>
</ingredient-list>
<instruction-list>
<step>Mix all ingredients</step>
<step>Microwave on HIGH 2 minutes</step>
<step>Stir until smooth</step>
</instruction-list>
</recipe>
Write a script that reads recipes in that format and outputs them in
another format. Store ingredients
and steps in an array each. Give the user two choices for the
output format (each should be handled by a subroutine):
a) normal text
b) html (leave the title tags, print "ingredient list" and "instruction
list" as h3 headings, print the instructions, steps as lists, add other
required html tags)