在此输入图像描述 我被要求准确地制作这个表,但我无法弄清楚定义的方法是如何工作的!?
我尝试了很多,但都失败了 不要,我做错了什么!
public class TABLE {
public int Multiplication;
public int multiply(int num)
{
for(int i = 1; i <= 10; ++i) {
System.out.printf("%d * %d = %d \n", num, i, num * i);
}
return multiply;
}
}
public static void multiply(int num)
{
for(int i = 1; i <= 10; ++i) {
System.out.printf("%d * %d = %d \n", num, i, num * i);
}
}
嗨,兄弟,你可以
//using user defined method By ITinnovation
import java.util.Scanner;
public class Table1
{
public void tab(int num1)
{
for(int i=1;i<=10;i++)
{
//System.out.println("The Table is:"+num1*i);
int multi=num1*i;
System.out.println(num1 + " x " + i + " = " + multi);
}
}
public static void main(String[] args) {
{
System.out.printf("Enter that value which you want to find out the table:");
Scanner sc= new Scanner(System.in);
int num1= sc.nextInt();
Table1 obj= new Table1();
obj.tab(num1);
}
}
}
// 使用类对象的乘法表
导入java.util.Scanner;
公共类 Mul_Table {
public void mul(int n)
{
for (int i = 1; i < 11; i++) {
System.out.println(n + " * " + i + " = " + n * i);
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Mul_Table m=new Mul_Table();
System.out.print("Enter Number = ");
int n = scanner.nextInt();
m.mul(n);
}
}