Calculator
Jisuanqi jsq=NewJisuanqi (); System. out. println ("The largest of the 2 and 3 are:"+jsq.max (2,3)); System. out. println ("The largest of the 2/3/10 is:"+jsq.max (2,3,Ten)); System. out. println ("The largest of the 2.3 and 4.5 are:"+jsq.max (2.3,4.5));
public class Jisuanqi {//attribute//model, Brand///method//1, method with the same name different parameters//2, return type and overload independent, only related to the type of the parameter. 3, more than one form of expression;//4, the construction method can also overload//addition operation public int max (int a, int b) {return (a>=b)? A:b;} Public double Max (double A, double b) {return (a>=b) a:b;} Public double Max (double A, double b, double c) {return Max (max (b), c);}}
First, write a class Chongzai that has 3 overloaded methods in void print (), and then write a main class to test the functionality of the Chongzai class.