010-003-005
Overloading by Type: Data Display
Medium
Problem Description
Overloading by Type: Data Display
In this problem, you will create a program that defines two overloaded display methods distinguished by parameter type (int and String), reads an integer and a string from standard input, calls both methods, and displays the results to standard output.
Learning Objective: Understand overloading with different argument types
Overview
Methods with the same name can be defined separately if argument types differ. Create methods with different processing for int and String types.
Input
integer value
string value
Specifications
- display(int) shows "Number: value"
- display(String) shows "Text: string"
- Read an integer and a string from standard input, then call both methods
Output Format
Number: integer value
Text: string value
Example
Input:
42
Hello
Output:
Number: 42
Text: Hello
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