「最初の数字は2番目の数字の倍数です」についてのビットを置き換えたいと思います。System.out.print(+ inta "は" + int b);の倍数です。何かアドバイス?私が使用しているコードは次のとおりです。
import java.util.Scanner;
public class Multiples {
public static void main( String[] args ) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter two integers " );
int a = scan.nextInt(); // First number input by user
int b = scan.nextInt(); // Second number input by user
if ( a % b == 0 )// is a a multiple of b
System.out.print("The first number is a multiple of the second.");
else
System.out.print("The first number is not a multiple of the second.");
}
}
あなたは簡単に行うことができます:
System.out.print( a + " is a multiple of " + b); // Or System.out.println()
または使用する printf()
System.out.printf("%d is a multiple of %d", a, b);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加