CS100J Spring 2004
Due Thursday 2/5 at 3pm
Completing all tasks in this assignment will help you:
First skim, and then carefully read the entire assignment
before starting any tasks! Note that you only need analytic, not programming, skill in this project. You should read each provided program to get an idea of what it does, then run it to check your understanding. Use the original statements in the program as examples when you make changes to the programs.
- learn about "ASCII file" (or "plain text file")
- find information and understand policies in CS100J
- run and edit simple Java programs
If you have questions on how to use DrJava, work in Carpenter Lab so that you can ask the CS100 consultant (not the CIT lab operator) on duty.
1. ASCII; course information and policies; using the newsgroup
Topics: what is ASCII?, creating an ASCII (text) file, course policies and procedures, accessing CS100 website and newsgroup
Read the following web pages to learn about ASCII. You may search the Internet for different articles on ASCII if you like.
Next, access the CS100J newsgroup and save the article with the subject line PROJECT 1 QUESTIONS, posted by Daisy Fan, to a file. Answer the questions by editing the file with any text editor or word processor. Be careful to keep the file as a plain text file (e.g., use WordPad or the DrJava editor). If you use a word processor like Microsoft Word, be sure to save the file specifically as a text file.
- Write the following information at the top of the file:
Name: your name
netID: your netID
Section: your section's instructor, day, and time
- Skip a line, write Project 1: Question 1,
and skip another line.
- Answer the questions inside this file by writing your responses after each question.
- Be neat! Keep line lengths to at most 70 characters.
- Save your work as an ASCII text file.
2. Temperature conversion
Topics: executing a Java program; from formula to program; arithmetic; type conversion; output format
Download the file Temperature.java from the Projects page. Read and then execute the program. The program compiles and runs but it is incorrect!
- Correct the mistakes in Temperature.java.
- Change the print statements to output the answer in one line of text
instead of two.
- Change the print statement(s) to output the answer (degrees C) as an
integer numeral (no decimal point). Do not change the variable
declarations and do not add any new variables. Hint:
Math.round(2.8) returns 3.0.
Topic: Java expressions;
Math functions; type conversion
Download the file Calculator.java from the Projects page. Read and then execute the program. Add code to class Calculator to perform the following operations and print the results. Notice that the solutions for questions a, g, and l have been provided and you should use a similar output format.
- 1/9 (output a decimal result)
- The remainder of 27/10
- The remainder of 3/10
- Determine the whole number (integer) portion of the quotient 58/10
- Determine the whole number (integer) portion of the quotient 10.6/3.8. Hint: Use a cast.
- Evaluate the expression "200 is equal to 99." (The corresponding code is 200==99)
- Evaluate the expression "200 is not equal to 99"
- 555/(112). Use method Math.pow
- Square root of |sin(4)|
- Generate a random floating point number in the range of 0 to 1. Use method Math.random
- Generate a random floating point number in the range of 0 to 6. Use method Math.random
- Generate a random floating point number in the range of 10 to 16. Use method Math.random
4. Submitting Your Work
You will submit all three files on-line using CMS (Course Management System) before the project deadline. See the CMS link on the web page for instructions on using CMS. In section (lab) on Feb 3rd and 4th, you will have a chance to test the CMS submission system. Do not attempt submission until after section.