CS100J Spring 2004
Project 1
Due Thursday 2/5 at 3pm

0. Objective

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.

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.

  1. Write the following information at the top of the file:
    Name: your name
    netID: your netID
    Section: your section's instructor, day, and time
    
  2. Skip a line, write Project 1: Question 1, and skip another line.
  3. Answer the questions inside this file by writing your responses after each question.
  4. Be neat! Keep line lengths to at most 70 characters.
  5. 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!

  1. Correct the mistakes in Temperature.java.
  2. Change the print statements to output the answer in one line of text instead of two.
  3. 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.

3. Calculator

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. (-10-2)+5
  2. 1/9 (output a decimal result)
  3. The remainder of 27/10
  4. The remainder of 3/10
  5. Determine the whole number (integer) portion of the quotient 58/10
  6. Determine the whole number (integer) portion of the quotient 10.6/3.8. Hint: Use a cast.
  7. Evaluate the expression "200 is equal to 99." (The corresponding code is 200==99)
  8. Evaluate the expression "200 is not equal to 99"
  9. 555/(112). Use method Math.pow
  10. Square root of |sin(4)|
  11. e3
  12. Generate a random floating point number in the range of 0 to 1. Use method Math.random
  13. Generate a random floating point number in the range of 0 to 6. Use method Math.random
  14. 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.