Write a program that takes an input value and outputs a string that identifies the value’s type.
Hints
General
Java
/*..:....1....:....2....:....3....:....4....:....5....:....6....:*/
// RTFM (Read the fine manual).
/* Start with a couple of classes. */
class Data {
}
public class YourType {
}
class Data {
}
public class YourType {
public static void main(String[] args) {
// Test Data.typeOf.
System.out.println(Data.typeOf(1));
System.out.println(Data.typeOf(2L));
System.out.println(Data.typeOf(3e100d));
}
}
class Data {
public static String typeOf(int x) {
return "The value " + x + " is an int.";
}
public static String typeOf(long x) {
return "The value " + x + " is an int.";
}
public static String typeOf(double x) {
return "The value " + x + " is an int.";
}
}
public class YourType {
public static void main(String[] args) {
// Test Data.typeOf.
System.out.println(Data.typeOf(1));
System.out.println(Data.typeOf(2L));
System.out.println(Data.typeOf(3e100d));
}
}