Monday, February 12, 2007

Exercises: Scripting

STRING MANIPULATION
===================
1. Write code that accepts a string as input and does the following
* Display the size of the string
* Display the string in reverse

2. Print the following string on 2 lines using one Msgbox function: "Hello" "World"
This should be printed as:

Hello
World

but done using 1 Msgbox function

3. Write code that takes the value 2000111.4 and displays it as $2,000,111.40

4. Write code that takes the value $1,234,567.70 and displays it as $1234567.70

5. Write code that accepts a number and displays whether the number is a prime number or not

6. Create a script that prompts a user for a word and then the script does the following:

a. Displays the string entered
b. Print out the length of the string
c. Print out the string in reverse



DATE MANIPULATION
=================
1. Write code that accepts a date in MM/DD/YY format and then prints the date in Mon, DD, YYYY format.
e.g. 03/01/04 and display Mar, 01 2004

2. Write code that displays the time in HH:MM AM format e.g. 02:35 PM

3. Create a script that will print out the day value e.g. Sunday/Monday

3. Write code that displays the time in long format e.g. Two thirty-five PM.



FILE I/O
========
1. Create a script that will accept an input and write it into a file named mydata.txt

2. Create a script that will accept a file name and print "Exists" if the file exists and "Doesn't Exist" if it doesn't.






MORE EXERCISES
==============
1. Create a simple loop that will print "Hello" 5 times




2. Write code that prints out all the even numbers between 2 and 8 and displays them at a single time using the following format:

2 - 4 - 6 - 8!

Labels: ,