010-004-002

Method Overloading: Tax Calculation

Easy

Problem Description

method overloading: Tax Calculation

In this problem, you will create a program that implements three overloaded methods named calculateTax() accepting int, double, and String prices respectively, calculates the tax-inclusive price (10% tax rate) for each type, and displays the result to standard output.

Learning Objective: Use overloading to provide same functionality for different input types

Implement overloaded methods named calculateTax() that accept int, double, or String prices. For String type, convert to a number using Double.parseDouble() before calculating. Tax rate is 10%.

Input

Read 3 lines:

  • Line 1: int price (integer)
  • Line 2: double price (decimal)
  • Line 3: String price (integer string)

Output

Tax included(int): [result] yen
Tax included(double): [result] yen
Tax included(String): [result] yen

Examples

Example 1: Basic values

Input:

1000
2000.0
2999

Output:

Tax included(int): 1100 yen
Tax included(double): 2200.0 yen
Tax included(String): 3298 yen

Example 2: Different values

Input:

5000
500.0
800

Output:

Tax included(int): 5500 yen
Tax included(double): 550.0 yen
Tax included(String): 880 yen

Example 3: Boundary values

Input:

0
0.0
10000

Output:

Tax included(int): 0 yen
Tax included(double): 0.0 yen
Tax included(String): 11000 yen

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
200
300.0
1500
Expected Output:
Tax included(int): 220 yen
Tax included(double): 330.0 yen
Tax included(String): 1650 yen
Normal case
Input:
4000
750.0
250
Expected Output:
Tax included(int): 4400 yen
Tax included(double): 825.0000000000001 yen
Tax included(String): 275 yen

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