1 /*2 Exercise 1: Define a feature to get the largest number of two integers3 Exercise 2: Define a function to determine whether the two numbers are equal. 4 Exercise 3: Define a feature to print a 99 multiplication table5 Exercise 4: Define a feature that does not simplify the output statement for a printed string6 do you have to write one idea before each exercise---two definite? 7 8 */9 classFunctionTestTen { One /* A Exercise 1: Define a feature to get the largest number of two integers - Ideas: - 1, clear the result of the function. is an integer. int the 2, clear unknown content, is two integer indeterminate, there are two shaping parameters - 3, if you want to get the big one, you can do it by comparison. The IF statement. - 4, return a larger value by using the return statement. - + */ - Public Static intGetmax (intAintb) + { A if(a>b) at { - returnA; - } - Else - returnb; - //return a>b?a:b; in } - to + /* - Exercise 2: Define a function to determine whether the two numbers are equal. the Ideas: * 1, clear result, Boolean $ 2, unknown content, two integersPanax Notoginseng */ - the Public Static BooleanIsequals (intAintb) + { A if(a>b) the { + return true; - } $ Else $ return false; - //return a>b?true:false; - //return a>b; the } - Wuyi the - /** Wu Exercise 3: Define a feature to print a 99 multiplication table - Ideas: About 1, results, no results $ 2, unknown content, no - */ - - Public Static voidprint99 () A { + for(intx=1;x<=9; x + + ) the { - for(intY=1;y<=a; b++ ) $ { theSystem.out.print (y+ "y*x" +x+ "*" +y*x "\ T"); the } the System.out.println (); the - } in } the the About /* the Exercise 4: Define a feature that does not simplify the output statement for a printed string the The output statement is cumbersome to write every time. the for simplicity, the statement can be encapsulated in a function + Pass the content you want to output as a parameter to the function - Benefits: Simplifies writing of output statements the Ideas:Bayi 1, clear, the */ the - Public Static voidSOP (String str) - { the System.out.println (str); the } the the - /* the by defining the main function, let the class run to verify that the feature is available? the */ the Public Static voidMain (string[] args)94 { the intmax = Getmax (4,6); theSystem.out.println ("max=" +max); the }98 About}/* - Exercise 1: Define a feature to get the largest number of two integers101 Exercise 2: Define a function to determine whether the two numbers are equal. 102 Exercise 3: Define a feature to print a 99 multiplication table103 Exercise 4: Define a feature that does not simplify the output statement for a printed string104 do you have to write one idea before each exercise---two definite? the 106 */107 classFunctionTest108 {109 /* the Exercise 1: Define a feature to get the largest number of two integers111 Ideas: the 1, clear the result of the function. is an integer. int113 2, clear unknown content, is two integer indeterminate, there are two shaping parameters the 3, if you want to get the big one, you can do it by comparison. The IF statement. the 4, return a larger value by using the return statement. the 117 */118 Public Static intGetmax (intAintb)119 { - if(a>b)121 {122 returnA;123 }124 Else the returnb;126 //return a>b?a:b;127 } - 129 the /*131 Exercise 2: Define a function to determine whether the two numbers are equal. the Ideas:133 1, clear result, Boolean134 2, unknown content, two integers135 */136 137 Public Static BooleanIsequals (intAintb)138 {139 if(a>b) $ {141 return true;142 }143 Else144 return false;145 //return a>b?true:false;146 //return a>b;147 }148 149 Max 151 /** the Exercise 3: Define a feature to print a 99 multiplication table153 Ideas:154 1, results, no results155 2, unknown content, no156 */157 158 Public Static voidprint99 ()159 { the for(intx=1;x<=9; x + + )161 {162 for(intY=1;y<=a; b++ )163 {164System.out.print (y+ "y*x" +x+ "*" +y*x "\ T");165 }166 System.out.println ();167 168 }169 } the 171 172 /*173 Exercise 4: Define a feature that does not simplify the output statement for a printed string174 The output statement is cumbersome to write every time. 175 for simplicity, the statement can be encapsulated in a function176 Pass the content you want to output as a parameter to the function177 Benefits: Simplifies writing of output statements178 Ideas:179 1, clear, the */181 182 Public Static voidSOP (String str)183 {184 System.out.println (str);185 }186 187 188 /*189 by defining the main function, let the class run to verify that the feature is available? the */191 Public Static voidMain (string[] args)192 {193 intmax = Getmax (4,6);194System.out.println ("max=" +max);195 }196 197}
The practice of Java_ function