- import java.util.Scanner;
- class TestFunctionMany {
- /*
- A:求两个数据之和
- B:判断两个数据是否相等
- C:获取两个数中较大的值
- D:打印m行n列的星形矩形
- E:打印nn乘法表
- */
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("请输入两个整数:");
- int num1 = sc.nextInt();
- int num2 = sc.nextInt();
- int sum = getSum(num1,num2);
- boolean isEqual = getBool(num1,num2);
- int max = getMax(num1,num2);
-
-
- System.out.println("由这两个整数可得以下结论");
- System.out.println("两个数据之和为" + sum);
- if (isEqual) {
- System.out.println("两个数据相等");
- }else {
- System.out.println("两个数据不相等");
- }
- System.out.println("两个数中较大的值为" + max);
- System.out.println(num1 + "行" + num2 +"列的星型矩形如下所示:");
- getPrintRectangle(num1,num2);
- System.out.println(num1 + "" + num1 + "乘法表:");
- ChenFaBiao(num1);
- }
- public static int getSum(int num1,int num2){
- return num1 + num2;
- }
- public static boolean getBool(int num1,int num2){
- return num1 == num2;
- }
- public static int getMax(int num1,int num2){
- return num1 > num2 ? num1 : num2;
- }
- public static void getPrintRectangle(int num1,int num2){
- for (int i = 1;i <= num1 ;i++ ) {
- for (int j = 1;j <= num2 ;j++ ) {
- System.out.print("*");
- }
- System.out.println("");
- }
-
- }
- public static void ChenFaBiao(int num1){
- for (int i = 1;i <= num1 ;i++ ) {
- for (int j = 1;j <= i ;j++ ) {
- System.out.print(i + "*" + j + "=" + i * j + "\t");
- }
- System.out.println("");
-
- }
- FenGeXian();
- }
- public static void FenGeXian(){
- for (int i = 0;i < 70 ;i++ )
- System.out.print("-");
- System.out.println("");
- }
- }
复制代码 |
|