public class Surcharge { private int n; private double x; public Surcharge() { n = 1; x = 3.5; } public Surcharge(int n, double x) { this.n = n; this.x = x; } public int operation(int p) { return 10 * p + n; } public double operation(double y, int p) { return x * p + y; } public double operation(int p, double y) { return (double) n / p + y; } } class EssaiSurcharge { public static void main(String[] arg) { Surcharge surcharge; surcharge = new Surcharge(); System.out.println(surcharge.operation(2)); System.out.println(surcharge.operation(1.5, 4)); System.out.println(surcharge.operation(4, 1.5)); surcharge =new Surcharge(7, 2.0); System.out.println(surcharge.operation(2)); } } /* On obtient : 21 15.5 1.75 27 */