010-002-001
Method Overloading: Score Aggregation
Easy
Problem Description
method overloading: Score Aggregation
In this problem, you will create a program that defines 3 overloaded aggregateScore methods with different argument counts and types, reads values from standard input, and displays each computation result.
Learning Objective: Use overloading for both argument count and type differences
Create 3 types of score aggregation methods. Define 2-argument, 3-argument, and weighted versions.
Method Definitions
- aggregateScore(int, int): Sum of 2 scores
- aggregateScore(int, int, int): Sum of 3 scores
- aggregateScore(int, int, boolean): Weighted sum (double score2 if true)
Input
a ← score1 for 2-arg method
b ← score2 for 2-arg method
c ← score1 for 3-arg method
d ← score2 for 3-arg method
e ← score3 for 3-arg method
flag ← boolean for weighted method (true or false)
The weighted method uses a, b, and flag.
Output
[result of aggregateScore(a, b)]
[result of aggregateScore(c, d, e)]
[result of aggregateScore(a, b, flag)]
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
80 90 75 85 95 true
Expected Output:
170 255 260
Normal case
Input:
50 50 60 60 60 true
Expected Output:
100 180 150
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 10 free executions remaining
