Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

What is a make-or-buy decision?

Answered: 1 week ago

Question

5. How does one adjust for small expected frequencies?

Answered: 1 week ago