008-004-002
Multiple Parameters Method: Total Price Calculator
Easy
Problem Description
Multiple Parameters method: Total Price Calculator
Learning Objective: Define methods with multiple parameters
In this problem, you will create a program that defines a calculateTotal method accepting three parameters (unit price, quantity, and tax rate), computes the total price (unit price × quantity × (1 + tax rate)), and displays the result to standard output.
Create a program calculating total price from three information pieces: unit price, quantity, tax rate. Pass multiple arguments to the calculateTotal method.
Input
Line 1: Unit price (integer)
Line 2: Quantity (integer)
Line 3: Tax rate (decimal, e.g., 0.1 is 10%)
Output
Unit price: [price] yen
Quantity: [quantity] items
Tax rate: [rate]
Total: [total] yen
Test Cases
※ Output examples follow programming industry standards
Input:
100 3 0.1
Expected Output:
Unit price: 100 yen Quantity: 3 items Tax rate: 0.1 Total: 330 yen
Input:
250 2 0.08
Expected Output:
Unit price: 250 yen Quantity: 2 items Tax rate: 0.08 Total: 540 yen
Input:
100 1 0.0
Expected Output:
Unit price: 100 yen Quantity: 1 items Tax rate: 0.0 Total: 100 yen
Input:
1000 1 0.1
Expected Output:
Unit price: 1000 yen Quantity: 1 items Tax rate: 0.1 Total: 1100 yen
❌ 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
