2A
You are going to practice using some String methods. Complete the class called FunWithStrings.
Do the following
- print 2.5 times the length of the given word (use a string method to find the length). If the length is 7, your code will print 17.5.
- print the word in uppercase
- in the original word, replace
"a" with "@"
"e" with "3", and
"s" with "$$" (2 dollar signs),
- print the word with the replacements
- now print the original word
You will need to use the replace() method multiple times. Then print the final string. Remember that replace is an accessor method. It returns the changed version of the string. If you want to do something with the returned string - like use replace on it again - you need to save the return value in a variable.
You are given a word in the starter file and Codecheck will test with that word and with a different word
For the draft, just print the length of the string multiplied by 2.5.
2A draft:
2A final:
2B
In this application you will use some of the methods of the Day class. Create a class called PlayDays. copy in the code form Codecheck. Also copy in the code for the Day class.
Do the following
- Step 1 (for the draft)
- Create a Day object representing January 26, 2015.
- Calculate the date 100 days from January 26, 2015.
- Print the month
- Step 2 (for the final)
- Remove the code for Step 1
- Create a Day object representing March 23, 2015.
- Calculate the date 300 days from March 23, 2015
- Print the year
- Print the month
- Print the day of the month (1, 2, 3 etc)
- Final print the entire date
For the draft, do step 1.
2B draft:
2B final:
2C
Draw the object below. It looks a little like a flight of stairs. Create a class called StairsViewer. Add a main method. There is no starter code this time.
Import the graphics package from Udacity. The URL is in the syllabus area.
Your drawing should follow these specifications.
- The upper left hand corner of the first step is at (10, 10).
- Each step has a height of 20 pixels
- Create the top step first. It has a width of 20 pixels. Fill it with red. (Use the predefined color in the Color class)
- Create the second step next. You figure out its coordinates. It has a width of 30 pixels. Fill it with blue. (Use the predefined color in the Color class)
- Create the bottom step last. You figure out its coordinates. It has a width of 40 pixels. Fill it with a custom color where red is 100, green is 100, and blue is 50.
For the draft, create the top step and fill it with red
Fill the rectangles. Do not use the draw() method. This will guarantee that Codecheck will correctly evaluate your code.
Just ignore the textarea labeled .DS_STORE. It is something Mac through in and I can not get rid of it. It will not affect your program.
Sample output

2C draft:
2C final: