Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AdditionMagic {
- // 1. Concatenates an integer and a String
- public String add(int a, String b) {
- return a + b;
- }
- // 2. Adds two doubles and rounds to 2 decimal places
- public String add(double a, double b) {
- double sum = a + b;
- // Multiply by 100, round to nearest whole number, then divide by 100.0
- double roundedSum = Math.round(sum * 100.0) / 100.0;
- return String.valueOf(roundedSum);
- }
- // 3. Concatenates two Strings
- public String add(String a, String b) {
- return a + b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment