Every computing environment is different, so it is hard to write instructions for this sort of thing (Preparation steps 1 and 2 below) that will always work on every computer no matter what. Please let me know if you find that your experience doesn’t quite match what I’ve described here, and more importantly, let me know if you get stuck!
- Get the required software set-up by following along with the appropriate tutorial below:
- Learn how to use Eclipse. Sometimes it can be a struggle learning how to use Eclipse. It’s important to get over that hurdle as quickly as possible. I strongly suggest that you work on the following right now. If you get stuck, you can post a message on the message board and start doing the reading assignment while you are waiting for a response.
- Start Eclipse
- Create a new project. Select File -> New -> Java Project. In the next window give it a name, for example “Project1”, and click “finish”. You should be able to see Project1 listed in the Package Explorer on the left.
- Create a new class. Select File -> New -> Class. In the next window give the class a name, for example “Hello”. You should see the file “Hello.java” appear in the Package Explorer. If you don’t, you might need to click on Project1 or one of the other folders to expand them.
- Delete the current contents of the editing window in the middle of your screen, and type (or paste) a Java program in that window. I would suggest the program from page 38 of your text.
- Save your file. Select File -> Save. Assuming that the “Build Automatically” option is checked in the Project menu (it will be, unless you’ve change it), saving your file will also cause your project to be built (or rebuilt).
- Fix Compiler Errors: Errors or warnings will appear in the Problems window at the bottom. (If you don’t have any compiler errors, you might want to type some random characters on the next line after your System.out.println() so that you can see what happens if you DO have errors.) If you double-click on one of the errors listed in the Problems window, it will take you to the line where the error occurred. Fix the error and save.
- When you have no errors, make sure that Project1 is selected in the Package Explorer, and Select Run -> Run As -> Java Application. You should see the output of your program in the console window at the bottom.
- If you are doing this for an assignment and you are ready to submit the assignment, copy all of the contents of the console window and paste them at the bottom of your source code file. Make the output into a comment by typing /* before it and */ after it. (So, */ will be the last 2 characters in your file.)
- Read text chapter 2 and watch the associated videos. You can skip the section “Compiling and Executing Your First Java Application” because we will not be using the command line to compile and execute our programs.
- For many assignments I will be providing detailed lessons. However, for this assignment you’ll need to depend more heavily on the text.
- Resources for help getting started with Eclipse:
Here is a tutorial with more information about setting up Eclipse and getting started.
Assignment 1.1 [5 points]
Introduce yourself — Click on the “MESSAGE BOARD” link in the right column. Click the “Register” button at the bottom left of the page, click on “I agree to these terms”, and proceed to register for the forum. Make sure to choose a username that includes your real name so that I can give you your participation points. You will then need to wait for me to activate your account.
When you receive your activation email, click on the “MESSAGE BOARD” link in the right column of the class website again. (I suggest that you always access the message board this way, rather than clicking on the link in your activation email.) Then click on the line that says “Introductions”. Click on the “POST REPLY” button and post your introduction. You can talk about your work, your computer experience, why you are interested in learning C++, etc. — whatever you would like your classmates to know about you. I would like each of you to also state whether you have any previous computer programming experience. Contributions of just a few words will not receive credit.
Note: I am using new forum software this quarter for the first time. Please let me know (and be patient) if there are any glitches. Thanks!
Assignment 1.2 [35 points]
We’ll keep it light. The main objective for this assignment is to get Eclipse set up and successfully compile and execute your first Java program.
Write a single program that produces all 4 of the following pieces of output (not 4 separate programs). There should be no output other than the output illustrated below.
- Produce the following screen output using one statement.
Tran says this is her first computer program.
- Produce the following screen output using two statements.
Tran says this is her
first computer program.
- Produce the screen output from part b), but use only one statement.
- Produce the screen output from part a), but use two statements (use each statement to produce about half of the output).
Assignment 1.3 [35 points]
Write a program that asks the user to enter a number of pounds, reads that value that the user typed, and then converts it to ounces and prints out the result. There are 16 ounces in a pound. In the following sample screen output, “4” is in bold to indicate that it is input by the user, not printed by the computer:
enter pounds: 4
4 pounds is 64 ounces.
Submit Your Work
Execute each program and copy/paste the output into the bottom of the corresponding source code file, making it into a comment. Send an email to firstname.lastname@example.org with the subject “CIS 254 a1”. Attach your source code file(s) to the email. In the body of the email let me know whether the programs work as required.
Keep in mind that if your code does not compile you will receive a 0.
Note that the gmail email account is for homework submission only. The account is not monitored for any other purpose.