010-002-006
Method Overloading: Tax Calculation
Easy
Problem Description
Method Overloading: Tax Calculation
Learning Objective: Use method overloading with different parameter counts in practical scenarios
Create 3 types of calculateTax methods. Define 1-parameter version (price only), 2-parameter version (price x quantity), and 3-parameter version (price x quantity - discount).
Method Definitions
- CalculateTax(int price): Tax on single price (price x 0.1)
- CalculateTax(int price, int quantity): Tax on total amount
- CalculateTax(int price, int quantity, double discountRate): Tax after discount
Output
[tax1]
[tax2]
[tax3]
Test Cases
※ Output examples follow programming industry standards
Input:
Expected Output:
100 500 400
Input:
Expected Output:
100 500 400
Input:
Expected Output:
100 500 400
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
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 9 free executions remaining
