1A

If you have not done so, create the directory structure specified in Lab0.

Start a new Bluej project called hw1a_numbers_draft in the cs46a/homeworks/hw01/draft folder. You can actually name the project anything, but this is a good naming convention that will help you keep things straight.

In the Bluej project, create a class called NumbersPrinter. (you must use this exact name to pass Codecheck).

Now write an application that prints the sum of the first eight even numbers on one line:  2 + 4 + 6 + 8 +... + 16

and then on the next line, prints the sum of the first ten powers of 2: 1 + 2 + 4 + 8 + ...+ 512.

(To have an application, you need a main method. It is provided for you)

For the draft, only print the sum of the first eight even numbers on one line.

Do not do the arithmetic on a calculator and simply display the answer. Actually have the computer do the work by doing the calculations in a System.out.println statement. (Look at Udacity lesson 1 "Text and Numbers" again if you have trouble)

When you think your code is correct, copy the whole class from Bluej and paste it into the textarea in the Codecheck draft link. Click submit. This will generate a HTML report about the correctness of your solution.

When you are ready to work on the final, copy the Bluej project (hw1a_numbers_draft) into the cs46a/homeworks/hw01/final folder. Change the word draft to final. This will help you tell the draft and the final when both are open in Bluej. Open the copied project (hw1b_numbers_final) in Bluej and complete the assignment.

Note: It is important to remember that Codecheck just helps you get your code to work. It does not submit it for grading. You must download and submit the report for grading in the Canvas Assignment area. See Submission directions at the bottom of the page.

It is important that you name your class exactly as specified otherwise Codecheck will not be able to process your submission and you will get no credit.

If you use an IDE like Eclipse or Netbeans, do not include a package statement. Codecheck will not be able to process your submission and you will get no credit.

To test your draft, click on the draft link below. Copy and paste the code from Bluej into the textarea and click submit. If your code passes the test, Congratulations. If not, go back to Bluej, make any necessary changes, and repeat the process.

See the Submission directions at the bottom of the page.

Follow a similar process for the final version.

1A draft:
1A final:

1B

Start a new Bluej project called hw1b_child_draft in the cs46a/homeworks/hw01/draft folder.

In the project, create a new class called ChildPrinter (you must use this exact name to pass Codecheck). In this application, you will display the word child in three different languages: English (child), Spanish (niño), and Czech (dítě).

Go to the Codecheck draft link at the bottom of the page. Copy the ChildPrinter class code you are given there into the class you made in Bluej. Add the code for the draft inside the main method.

The completed final version will display the words exactly as shown.

output

For the draft, just print the first two lines like this

output for draft

When you think your draft code is correct, copy the whole class from Bluej and paste it into the textarea in the Codecheck draft link. Click submit. This will generate a HTML report about the correctness of your solution.

When you are ready to work on the final, copy the Bluej project (hw1b_child_draft) into the cs46a/homeworks/hw01/final folder. Change the word draft to final. This will help you tell the draft and the final when both are open in Bluej. Open the copied project (hw1b_child_final) in Bluej and complete the assignment.

The third and fourth lines in the printout needs more explanation. The third line is the word for "child" in the Spanish. But how do we get that tilde (~) over the n? Well, every printable character in English and most other languages is represented by a hexadecimal number (it is called Unicode). When you type a character on your keyboard, the computer software takes care of translating the character to its Unicode representation. But when we want to display a character that is not on the keyboard like ñ, we have to supply the Unicode ourselves. We could also specify the English characters directly with Unicode Here is a table of a few characters and their Unicode values

Character Unicode
c \u0063
a \u0061
t \u0074
ñ  \u00f1
í  \u00ed
ě  \u011b

In Java, the "\u" is an escape sequence which tells the compiler that the following characters have a special meaning, the Unicode for some character.

The following two statements will display the same results: the word "cat" The first uses the Unicode values for the letters.

System.out.println("\u0063\u0061\u0074");
System.out.println("cat");

And this will print the Spanish word for year (año)

System.out.println("a\u00f1o");

Note: It is important to remember that Codecheck just helps you get your code to work. It does not submit it for grading. You must download and submit the report for grading in the Canvas Assignment area. See Submission directions at the bottom of the page.

It is important that you name your class exactly as specified otherwise Codecheck will not be able to process your submission and you will get no credit.

If you use an IDE like Eclipse or Netbeans, do not include a package statement. Codecheck will not be able to process your submission and you will get no credit.

To test your draft, click on the draft link below. Copy and paste the code from Bluej into the textarea and click submit. If your code passes the test, Congratulations. If not, go back to Bluej, make any necessary changes, and repeat the process.

See the Submission directions at the bottom of the page.

Follow a similar process for the final version.

1B draft:
1B final:

1C

This is an image of a redwood tree. It is very tall and thin. We are going to write an application that will draw it even taller and thinner.

Download redwood.zip which contains all the files you will need, the graphics classes, the starter file.  Download the file, unzip it into your cs46a/homeworks/hw01/draft folder, and rename the file to hw1c_redwood_draft. (See Lab 1 Part B for directions on unzipping a file correctly in Windows.)

To download an image from a web site, right click the image and select "save image as" or some such.Put it in your hw1c_redwood_draft folder

Start Bluej. Open the redwood project by clicking Project > Non Bluej and selecting the folder hw1c_redwood_draft and click Open in Bluej. Compile the classes. Your workbench will look like this.

workbench

Complete the Redwood class following these instructions

You will do this in code, in the main method or the Redwood class. Do not do it in the Bluej workbench. You can't submit that. Look at Udacity video Lesson 2, the section named variables to see how to create a Picture object in the main mehtod of a class.

For the draft, just create the picture and draw it. Don't translate or grow it until the final version.

1C draft:
1C final:

Submission

When you are finished with your code, submit it in Codecheck one final time. Notice at the bottom left there is a "Download" button. Click that and a .signed.zip file will be downloaded. That is the file you need to upload into Canvas.

When you are working on the draft, add the word "draft" to the end of the name, before .signed.zip after downloading. For example ChildPrinter_draft.signed.zip. (Leave .signed.zip alone and do not add any extra dots)

When you are working on the final, add the word "final" to the end of the name, before .signed.zip. For example ChildPrinter_final.signed.zip. This will help avoid submitting the wrong version.

Be sure to upload the .signed.zip file produced by Codecheck not the .java file you wrote. Do not open and alter the downloaded file in anyway. The files are digitally signed and the graders will check that they have not been altered.

For both the draft and the final, you will upload 3 signed.zip files. Upload all three programs at one time. Double check in Canvas that the files were uploaded

Warning: do not submit the final version as the draft. In order to be graded correctly, you must submit a program that does exactly what is specified for the draft - no more, no less.