CS 141 - Project 1 - Spring 2007
D. Noonan

Due: Wed. Feb. 21, 8 AM
Submit Project: Proj1
Required Files: Proj1.java
Grading Header: header1.txt
Test files: testa.dat, testb.dat, testc.dat
Sample output: out.dat

Though the semester is not very old, you know about variables, their types, and about Java statements that make assignments to them. You know about constants. You know how to write arithmetic expressions. You know the fundamentals of input through the keyboard and output to the monitor screen. You also know how programs are formatted. This project will give you a chance to work with all these things.


Program Description

One way to produce a geometric model of a doughnut with a rectangular cross section would be to revolve a rectangle of Height H and width W about an axis AA'. To make sense of that sentence, refer to the figure below and its notation.

The development of your project will require you to find the surface area and the volume of a rectangular doughnut in terms of its radius, R, its width, W, and its height, H. The formulas you will need are:

Volume = π x (2 x R + W) x W x H
Surface Area = 2 x π x (H + W) x (2 x R + W)

Your program will prompt a user to enter the radius, a height and a width, in that order, for the doughnut. The input will be provided from keyboard. Finally your program will write to the screen (in a very tightly specified format) the three data items (radius, height, and width) and the two computed numbers, the surface area and volume of the doughnut.


Project Specifications

  1. Your program must be in a file named Proj1.java.
  2. Make sure you remember to import all libraries that you need.
  3. Declare all numeric variables as doubles.
  4. You must declare three variables to hold the radius, height and width. You will also need other variables to handle the volume and surface area values.
  5. Your program must carry out the following interaction with the user:
  6. Your program must compute the volume and surface area of the doughnut by using the formulas above.
  7. Next your program should print the radius, height, width, volume and surface area in the format described in the section Output Specifications. Your output should match the example very closely.


Output Specifications

Directly below, you can see the display which will appear on the monitor screen during the data prompting, data gathering, and data echoing phase of the program. Note that no formatting specifications are in effect at this point in the program. (Input from keyboard is underlined.)

Please enter the doughnut's radius ==> 2.034
2.034
Please enter the doughnut's height ==> 3.17763
3.17763
Please enter the doughnut's width  ==> 1.3
1.3 

The output from a single run of your program must match the following as closely as possible. In particular, a blank line followed by a line of hyphens and another blank line must separate the input prompting from the start of output. Three digits must be shown to the right of decimal points in every number displayed. (Unfortunately, there is no easy way to line up the decimal points.)


-----------------------------------

  The doughnut's radius = 2.034.
  The doughnut's height = 3.178.
   The doughnut's width = 1.300.
             Its volume = 69.664.
       Its Surface Area = 151.022.

-----------------------------------


Specifications for Documentation and Format

Normally you will be expected to determine what documentation and formatting will be necessary for your project on your own, with the help of the Style Guide in your Lab manual. But this is, after all, your first project. Fully correct documentation for Project 1 must follow the javadoc conventions and include:


Program Testing

You would be wise to test your program using the test and data files that the Teaching Assistants will use to grade your programs. Links to sample input files are below along with a file containing the expected output.


Submission

Submit your program file electronically. In Eclipse, right click on the project and import the files from /home/f85/debbie/cs141/Proj1. Right click on the file submit.xml and select Run - > 1 Ant Build; Messages will appear in the Console window. Be sure to determine whether you got the Build Successful message to ensure that your electronic file submission for this project was successful.

Honor Code. The honor code applies to all programming done in this course. Reread the CS Department's document: Programming Assignments and the Honor Code.

Great Advice: Get started early and have fun!


Debbie Noonan, debbie@cs.wm.edu
February 1, 2007