Comparing numbers with the static method


Question 1) Write a java program which

(1) uses the single line comment to document your source code with your name and section number. This must be the very first line of your program,

(2) uses a println statement to print your name and section number as first line of your output,

(3) Write the class Compare3 which provides the static method largest. Method largest must take three Comparable parameters and return largest of three (so its return type would also be Comparable). Recall that method compareTo is part of Comparable interface, so largest could use compareTo method of its parameters to compare them.

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

(a) First prompt user for and read in three strings, use your largest method to determine the largest of the three strings, and print it out (It's easiest to put call to largest directly in the call to println.) Note that since largest is the static method, you would call it through its class name, e.g., compare3.largest(val1, val2, val3) and

(b) Add code to also prompt user for three integers and try to use your largest method to determine the largest of the three integers. Does this work? If it does, it's thanks to autoboxing, that is Java's automatic conversion of ints to Integers.

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

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Comparing numbers with the static method
Reference No:- TGS04532

Expected delivery within 24 Hours