Your instructor will assign one or more of the following problems. Submit all appropriate files for grading, including code files, screen captures, supplemental files (e.g., image files), and text files.
class by adding these methods:
doubleequivalent of the fraction.
Name the relational operators with an
, etc. This will avoid a technical problem or two.
Extend the console testing application that you started in the lab to include appropriate test cases for these new features.
A quadratic equation has the form
ax^2 + bx + c
where the coefficients
are all real values, and
cannot be zero. Write a class
that can be used to model a quadratic equation. You’ll need
constructors (that maintain the invariant), accessors, and a
method (but no mutators). Also include two computation methods:
b^2 - 4ac, if greater than or equal to zero).
Write a console test application that tests your methods on at least five different quadratic equations. Be sure to include tests for zero and negative coefficients.
A phone number consists of four separate pieces of information: an
area code, an exchange, a local number, and a long-distance
indicator (true or false). Design and build a
class that models a phone number, providing operations to construct
object, access each of its attributes, and indicate whether or not
the number is long-distance. Finally, add a method that compares two
phone numbers and indicates whether they have the same area code.
Note that 911 is not a valid area code. The toString() method should
present a local number differently from the way it displays a
long-distance number (e.g.,
Your instructor may also ask you to implement input and output operations. The input operation should read a local or long-distance number and set the long-distance indicator accordingly.
Write a console application that tests the basic operations of this class.
A dual stop watch can time two runners simultaneously. It has one
button to start the timer and two buttons to stop the timer (one for
each runner). It will have three attributes for keeping track of the
time: a start time and for each runner a stop time. It will also
have two attributes that indicate the state (running or not running)
of the stop watch for each runner. Design and build a
class that models a stop watch. Your class should provide operations
to construct, start timing, stop the timer for either runner, and
display the time for either runner. If the stop watch is running,
you should display the current elapsed time. If the watch is not
running you should display the final elapsed time.
Hint: You can get the current system time in milliseconds using the
via this code:
long current = (new Date()).getTime();
To test your classes, write a console application that starts the watch and prompts the user to stop it. Make sure to check all the operations of the stop watch.
PropertyRecordclass that models a property. Each property will have a street address, a number of bedrooms (integer) and a number of bathrooms (double -- a half bathroom does not have a shower/tub). The number of bedrooms and bathrooms must both be at least one. Your design should include the following:
toString()method that prints using this format: 3201 Burton SE (6 beds, 3.5 baths).
Write a console test application that tests your methods on at least five different properties. Be sure to include tests for invalid property records.
Submit all appropriate files for grading, including code files, screen captures, supplemental files (e.g., image files), and text files. We will grade this exercise according to the following criteria:
If you work in teams for this homework assignment, be sure to submit all team members’ names in the code documentation.