Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a java program that (3) Write a class Compare3 that provides a static meth

ID: 3545504 • Letter: W

Question

write a java program that

(3) Write a class Compare3 that provides a static method largest. Method largest should

take three Comparable parameters and return the largest of the three (so its return type will

also be Comparable). Recall that method compareTo is part of the Comparable interface,

so largest can use the compareTo method of its parameters to compare them.

(4) Write a class Comparisons whose main method tests your largest method above.

(a) First prompt the user for and read in three strings, use your largest method to find

the largest of the three strings, and print it out (It's easiest to put the call to largest

directly in the call to println.) Note that since largest is a static method, you will call it

through its class name, e.g.,

compare3.largest(val1, val2, val3) and

(b) Add code to also prompt the user for 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 Java's automatic conversion of ints to Integers.(10 Points)



also if you can do this java program i will increase points

write a java program that prompts the user to enter a number, its base, and base to be converted to reads these inputs from the keyboard and stores the number in a double "num", base b in int"b", base a in int "a". uses iteration to calculate the conversion of numa to numb.uses iteration to calculate the conversion of numb to numa, and a the values of the conversions in appropriately formatted and informative manner.

please answer, i will rate

Explanation / Answer

##########Compare3.java#############

public class Compare3 {

public static <T extends Comparable<T>> T largest(T a, T b, T c) {

if (a.compareTo(b) > 0 && a.compareTo(c) > 0) {

return a;

} else if (b.compareTo(a) > 0 && b.compareTo(c) > 0) {

return b;

} else {

return c;

}

}

}

import java.util.Scanner;

public class Comparisions {

public static void main(String args[]){

System.out.println("Largest of abcd, defghi, ab is : "+Compare3.largest("abcd", "defghi","ab"));

Scanner input = new Scanner(System.in);

System.out.println("Enter 3 integers");

System.out.print("Enter first integer :");

int num1=input.nextInt();

System.out.print("Enter second integer :");

int num2=input.nextInt();

System.out.print("Enter third integer :");

int num3=input.nextInt();

System.out.println("Largest of "+num1+", "+num2+", "+num3+" is : "+Compare3.largest(num1, num2,num3));

}

}

Largest of abcd, defghi, ab is : defghi

Enter 3 integers

Enter first integer :1

Enter second integer :2

Enter third integer :51

Largest of 1, 2, 51 is : 51