每天多敲即便代码:
import java.util.Scanner;
class Demo_Method
/*
函数的练习:
A:求两个数据之和
B:判断两个数据是否相等
C:获取两个数中较大的值
D:打印m行n列的星形矩形
E:打印nn乘法表
*/
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("请输入第一个整数");
int a=sc.nextInt();
System.out.println("请输入第二个整数");
int b=sc.nextInt();
System.out.println("最大值是:"+getMax(a,b));
boolean b1=isEquals(a,b);
System.out.println(b1);
System.out.println("两个数的和为:"+add(a,b));
printStar(a,b);
print99(a);
}
public static int getMax(int a,int b){
return (a>b)? a :b;
}
public static boolean isEquals(int a,int b){
return (a==b);
}
public static int add(int a,int b){
return a+b;
}
public static void printStar(int a,int b){
for (int x=1;x<=a ;x++ ){
for (int y=1;y<=b ;y++ ){
System.out.print("*");
}
System.out.println();
}
}
public static void print99(int a){
for (int x=1;x<=a ;x++ ){
for (int y=1;y<=x ;y++ ){
System.out.print(x+"*"+y+"="+x*y+"\t");
}
System.out.println();
}
}
|
|