Untitled

mail@pastecode.io avatar
unknown
java
a month ago
570 B
0
Indexable
Never
public class Calculator {
    public int add(int a, int b) {
        return a + b;
    }

    public double add(double a, double b) {
        return a + b;
    }

    public int add(int a, int b, int c) {
        return a + b + c;
    }
}

public class Main {
    public static void main(String[] args) {
        Calculator calc = new Calculator();
        System.out.println(calc.add(5, 3));       // Output: 8
        System.out.println(calc.add(5.0, 3.0));   // Output: 8.0
        System.out.println(calc.add(1, 2, 3));    // Output: 6
    }
}
Leave a Comment