010-004-003

Overloading in Practice: Format Utility

Easy

Problem Description

Overloading in Practice: Format Utility

In this problem, you will create a program that defines multiple overloaded format methods for integer, decimal, and string types, and displays each value in the specified format to standard output.

Learning Objective: Understand practical use of overloading

Define multiple format methods to format and display integer, decimal, and string appropriately. Use same interface to handle different types.

Input

Line 1: Integer value
Line 2: Decimal value
Line 3: String

Output

Int format: [integer]
Double format: [decimal]
String format: [string]

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
100
3.14
Hello
Expected Output:
Int format: 100
Double format: 3.14
String format: Hello
Boundary case
Input:
0
0.0
Empty
Expected Output:
Int format: 0
Double format: 0.0
String format: Empty

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining