我的教科书中有一个问题:
编写一个方法倍数,它将两个整数作为参数,如果第一个整数可以被第二个整数均分,则返回true(即,除法后没有余数); 否则,该方法应返回false.将此方法合并到一个应用程序中,使用户可以输入值来测试方法.
我写了这段代码,但它不起作用:
public class project1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a, b;
System.out.println("enter the first number");
a = input.nextInt();
System.out.println("enter the first number");
b = input.nextInt();
}
public static boolean multiple(int g, int c) {
int g, c;
if (g % c = 0) {
return true;
} else {
return false;
};
}
}
Run Code Online (Sandbox Code Playgroud)