CS139
Algorithm Development
|
Software
Requirements Specification
Programming Assignment 2
Physics
Due Friday, October 8 by 5:00pm
Introduction
Purpose: You are taking a physics class and there are SOOOO
many formulas to use. As a CS 139 student, you have used the Math class
functions and have found them to be pretty handy. So, you decide to make a
Physics class that will contain methods to help you with those formulas.This
program will result in a Physics class and also introduces you
to a new concept, the checkExpect.
Objectives - At the
conclusion of this exercise the student will demonstrate that they can:
- Use both value returning and void methods.
- Precisely follow specifications for methods.
- Use a generic driver to "exercise" your programs.
- Do everything necessary to
create, debug, and run a java program.
- Use comments to delineate
each section of the program.
- Use the checkExpect methods to assist in testing code.
- Adhere to a Style Guide.
- READ
AND FOLLOW DIRECTIONS!!!!!
Deadlines
- Submit: October 8th, 2010
by 5:00pm.
- Report: October 11th, 2010
at
the beginning of class. A late penalty will apply for
each of the 2 deadlines. If the submit is late, the report is due the
next class or lab session day after successful submission.
Programs will not be accepted after 7 days late.
Prerequisites
You have covered the material in Chapter 5 of Gaddis.
Program
Behavior
The driver program, PhysicsTester.java,
contains a main method that will run each of the
methods in Physics, and produce output that indicates whether your methods
conformed to the expected behavior. Method headers containing the name of the
method, input parameters, and return type are found in the file,
Physics.java. You must use these headers.
Physics Methods
There are a lot of formulas to describe various
kinds of motion in physics. We have just a few here; you may add
additional methods if you like to your Physics program. Your
program must be able to calculate the following:
- The falling distance of an object due to gravity. The formula is d = 1/2 gt2 where d is the distance in meters and g is the gravitational constant, 9.8, and t is the amount of time in seconds.
- The distance a vehicle travels. The formula is distance = speed *
time. Speed is expressed as kilometers per hour and time is expressed
in hours.
- The kinetic energy of an object in motion. The formula is KE = 1/2 mv2 where KE is the kinetic energy, m is the mass in kilograms, and v is the velocity in meters per second.
- The final velocity of a vehicle. The formula is v = u + at where
v is the final velocity in meters per second, u is the initial velocity
in meters per second, a is the acceleration in meters per second squared, and t is the time in seconds.
- The momentum of a moving object. The formula is p = mv where p is
the momentum, m is the mass of the body in kilograms, and v is the
velocity in meters per second.
In addition to the physics method, we want a helper method that can be
used to take the long numbers returned by the physics methods and
return a formatted String. This method will take in a double value and
a precision and will return a number formatted to the given precision.
This will save us from having to create DecimalFormat objects or to use
String.format for each value we want to output.
Output
You do not need to worry about formatting the output. The only formatting that
you will be doing is to produce a String representation of a double number to
the number of decimal places prescribed.
Error Handling
The methods do not need to worry about error handling.
Additional Program Requirements
- You must use the method headers as provided in the
Physics.java
file.
- Your program must conform to
standard Java programming standards and the additional standards for
this class. See the Style Guide for your class. You must document each of your methods using the standard method formats.
- You must create a program called MyTester
which will be copied from the PhysicsTesterthat
we provide, but should include more tests for each of your
methods. This program will be attached to your successful pdf
report and may be printed from your editor. It will not be evaluated
for conformance to style, but instead will be evaluated for the quality
of your test cases.
Honor Code
This work must conform to the
JMU Honor Code and the specific requirements
of this class. NO help may be provided by any student to another
student.
Authorized help is limited to your textbook, the TAs for any
CS139
section, and the professor for your section. See collaboration
policy.
Grading
- Your program will be
evaluated both by its correctness and conformance to the required
elements.
- You will achieve a grade of
70 for a program that runs correctly
and produces exactly the required output in the required format.
- You should provide a "main" program called MyTester which
contains at least one call to each method. You will not submit
this file, but will print it as a text document and attach it to your
pdf report. I will not evaluate MyTester for conformance to style as it is
a tester for you to use.
- The remainder (20 points)
will be
based on your conformance to the Style and other requirements of the
assignment. Review the Style
Guide before submitting your
program and the grade sheet which is produced by the submit system.
- All grades will be based on
100 points.
- You may submit any number of
times. The only one I will count is the one that corresponds to the
hardcopy report that you turn in.
- The hardcopy that you turn
in will be the formatted version that
I will check. Make sure it has no line wraps or other spacing
issues.
- Successfully submitted
programs that are late will be graded, then the late penalty is
assessed for each day late according to the following schedule.
For
submissions after:
- Oct. 8 - 5 points
- Oct. 10 - 15 points
- Oct. 11 - 25 points
- Oct. 12 - 35 points
- Nov 13 - 45 points
- Nov 14 - 100 points
HINTS
- Begin early.
Students run into trouble by waiting too long to start the
program.
- Write and test one method at a time. Get it working well
(using your MyTester), then move on to the
next method.
- Understand the problem at
hand. Make sure that you follow
the requirements precisely. Don't add additional
"flourishes".
You will be downgraded.
- In the body of your main
method, outline your steps with comment lines for each part of the
project.
- If you wish to use additional methods to break up your code, feel
free to do so.