Spring 2003
(Sections 02 & 03 only) |
Program # 1
Pgm1a due by 9 p.m. Friday, Pgm1b due by 9 p.m., Sunday, at the end of Week # 2. DON'T FORGET TO USE THE handin INSTRUCTIONS linked below, my account is "csturner" and does NOT include "cpe101" or a section number. The handin instructions given on the main csc/cpe 101 webpage has you use your course and section number, but that will not work for this class. |
Writing and compiling Java programs will be covered in lab during week #1. Using the "handin" process that you must use to submit this assignment will be covered in the first lab session of week #2: all course participants must have obtained their Central Unix account by the start of our lab during the second week.
Here again is a link to an explanation of the handin process you must use to submit your programming assignments to me.
Start with either your assignment template, that you created in Lab 1, or download another copy of my Template1 and re-enter all your own personal information. Then, for each program described below, make a copy with the appropriate changes. For example, for the first part below, you'd save it as SimpleMath.java
and, when prompted to make the other necessary changes, you should do all of the following:
SimpleMath
Program 1.1, A Simple Math Program
SimpleMath
Then, when you start the second program below, start with the template again, and make the changes necessary for it. You'll find reminders about these steps throughout this assignment, and only this one, but you should follow a similar process for every program you write for this course.
handin
to the Pgm1a
folder
The first program is due by 9 p.m. Friday. FOR THIS ONE PROGRAMMING PART (and ONLY this programming part, Pgm1a) you are allowed to work with a partner if you wish, but you MUST note that on your program documentation, including the nature of the help given and the name of the partner.
The challenge here is to successfully:First, practice writing some simple Java applications using arithmetic expressions.
SimpleMath.java
(use exactly that name, capitalization and all).
x = 5
on one line, y = 8
on the next, etc.
x + y = 13
but, even better, you could display x + y = 5 + 8 = 13
where, once again, the x and y are printed literally but all the numbers must be from the variables themselves.) Compile and execute. Check that the value is correct. y/x.
Compile and execute. Is the value what you expected? Do both of the following:
y % x
. Compile and execute. Is the value what you expected? Once again, note this in your course notebook and in a comment in your program.y + z / x
. Compile and execute. Check that the value is correct. (y + z) / x
. Compile and execute. Compare this result with that of the previous step, and either confirm that the value is correct or resolve any discrepancies that you notice. Note this in your course notebook and in a comment in your program.(double) (y + z) / x
. Compile and execute. Compare this result with that of the previous step, and either confirm that the value is correct or resolve any discrepancies that you notice. Once again, note this in your course notebook and in a comment in your program.Make sure you save this program when you are done. Continue with the next part of this lab. When you get to the end, you'll find instructions on how to hand in this source code file for grading.
handin
to the Pgm1b
folder
The remaining program is due by 9 p.m. Sunday. You may, of course, submit the last program at the same time as you submit the first one (using the appropriate handin
folder for each set), but I'm splitting this assignment into two parts because I want everyone to get started using handin
during the week (rather than waiting until the weekend, when less support is available for anyone having difficulty...).
The challenges here are to successfully:
For our last program, we will develop a very simple, text-based "dice roller" game. Each time you play this game, a pair of six-sided dice are rolled (but write your program such that those numbers can be easily changed in future versions; i.e., use variables with meaningful names for both the number of die pieces and number of sides on each one). Your program is to print out a message indicating the face that appeared (randomly, of course) on each individual die, and the total number of points for the roll.
While you won't be given directions on exactly how to write design this, as you were for the first part of this assignment, all of the following are required for this program:
TwoDice.java
For this and all future programming assignments, you will submit your source code files (and, unless explicitly told otherwise, only those .java files) via the Central Unix Handin facility. It is recommended that you first try submitting a file or two to the Test folder, to familiarize yourself with the process (although work submitted there will NOT be graded). Once you think you understand the process, then submit these files as noted:
Pgm1a
folder (which will close at 9 p.m. on Fri, April 11):
SimpleMath.java
Pgm1b
folder (which will close at 9 p.m. on Sun, April 13):
TwoDice.java
Please Note: Only programs that we can compile successfully in our lab environment will be graded. (Compiling in your, possibly different, environment is not adequate. They must compile in the CSc Lab.) Programs that do compile, but contain errors, may be eligible for partial credit if and only if you make it clear that you are aware of the program's limitations by documenting all problems you know about and the things you have tried, unsuccessfully, to fix them. You may document this in one of two ways: