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.
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
Please find the... View the full answer