010-003-011
Overloading by Parameter Type
Easy
Problem Description
Overloading by Parameter Type
In this problem, you will create a program that reads an integer, a double, and a string from standard input (one per line), defines three overloaded display methods with different parameter types (int, double, and String), calls each with the corresponding value, and displays the result to standard output.
Learning Objective: Understand how to overload methods by varying parameter types
Overview
In method overloading, methods with different parameter types can have the same name. The compiler automatically selects the appropriate method based on the argument type.
Specifications
- Define three display methods:
- display(int value): displays "Integer: " + value
- display(double value): displays "Double: " + value
- display(String value): displays "String: " + value
- Read from standard input in order:
- Line 1: int value
- Line 2: double value
- Line 3: String value
- Pass each read value to its corresponding display method
Input Format
integer_value
double_value
string_value
Output Format
Integer: integer_value
Double: double_value
String: string_value
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up