Variable Lab Exercises:
Pig Latin:
Step 1: Write a program with the variable first set to your first name. The
name should be lowercase. Your program should then create a string that contains
your name in pig latin with the first letter capitalized. Use the pig latin
rule of moving the first letter to the end of the word and adding ay.
Then, make the first letter of the resulting name be the only capitalized letter.
Use substring and toUpperCase String methods.
Ex: Kris becomes risKay
Step 2: When you are done, change the first name to another name to see whether it works. Be sure to capitalize the first letter of your initial name.
Step 3: Change the name variable to expect a full name. Use indexOf method and substring to extract the first and last name and turn both of these into pig latin, with the first letter of each name. Test with different names.
Step 4: Move the full name's variable initialization into the method header. Test again using different names.
Counting Change:
Set an integer variable of needed change to 332. Calculate the change giving first as many dollars as possible, then as many quarters, and then as many dimes and then as many nickels and then finish with pennies. Write the number of dollars, quarters, dimes, nickels and pennies on the terminal.