View the step-by-step solution to:

q1 - RationalNumber Modify the RationalNumber class so that it implements the Comparable interface.

q1 - RationalNumber
Modify the RationalNumber class so that it implements the Comparable interface. To perform the comparison, compute an equivalent floating point value from the numerator and denominator for both RationalNumber objects , then compare them using a tolerance value of 0.0001.

q2- Student
Modify the Student class presented in this chapter as follows:
Each Student object should also contain the (integer ) scores for three tests.
Provide a constructor that sets all instance values based on parameter values , with the score parameters coming last in the list.
Overload the constructor so that each test score is assumed to be initially zero.
Provide a method called setTestScore that accepts two parameters : the test number (1 through 3) and the score.
Also provide a method called getTestScore that accepts the test number and returns the appropriate score.
Provide a method called average that computes and returns an integer average test score (the average rounded to the nearest integer ) for this student.
Modify the toString method so that the test scores and average are included in the description of the student. The String returned should be the same as the original with a string of this form appended as an additional line:
Average=A with Tests: S1, S2, S3
where A is the (integer ) average and S1 S2 and S3 are the test scores

Sign up to view the entire interaction

Top Answer

Please find the... View the full answer

public class Address {
private String streetAddress, city, state;
private long zipCode;
// ----------------------------------------------------------------// Constructor: Sets up this address with...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online