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.
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.
Proj1.java.
println statement that will display the user's input on
the screen; i.e. System.out.println(radius);. This is
called "echo printing" and you will need to do it all semester for
all keyboard input. (Echo printing helps you verify that there have been no
problems in obtaining input, that the correct input has been stored, and
it helps us grade your projects. You will echo print every single input
obtained from keyboard in every project written for this course. Get
used to it.)
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. -----------------------------------
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:
} // main
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.
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!