Question: 1. Write a class Compare3 that provides a static method largest. The method takes three parameters of Comparable type and returns the largest of

1. Write a class Compare3 that provides a static method largest. The method takes three parameters of Comparable type and returns the largest of the three (that is, the return type should be also Comparable). Use the compareTo method in the largest method to compare the passed values. Recall that the method compareTo is part of the Comparable interface, so the largest method can use the compareTo method to compare the passed parameters. 3. Write the driver class Comparison to test your largest method in the main method. First prompt the user to enter three strings, use your largest method to find the largest of the three strings, and print it out (it's the easiest to put the largest call directly in the println). Add code to prompt the user to enter three integers and try to use your largest method to find the largest of the three integers. Does this work? If it does, it's thanks to autoboxing, which is automatic conversion of ints to Integers. 3. Draw a UML class diagram. Deliverables The program and final execution. - UML class diagram Output Example String comparison: Enter string0: Tom Enter string1: bob Enter string2: steve The largest string is: steve Integer comparison: Enter integer0: 34 Enter integer1: 7 Enter integer2: 123 The largest integer is: 123
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
