In: Computer Science
Debug the code in the starter file so it functions as intended and does not cause any errors. This program is intended to take two integer inputs and determine whether the second is a multiple of the first or not. The number b is a multiple of the number a if b can be divided by a with no remainder. Remember though that no number can be divided by 0 - so no numbers should be considered a multiple of 0 for the purpose of this exercise.
/* Lesson 5 Coding Activity Question 2 */
import java.util.Scanner;
public class U3_L5_Activity_Two{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter two numbers");
int a = scan.nextInt();
int b = scan.nextInt();
if((b % a =! 0 | a == 0)
System.out.println(b + " is not a multiple of " + a);
else
System.out.println(b + " is a multiple of " + a);
}
}
import java.util.Scanner;
// Defines class U3_L5_Activity_Two
public class U3_L5_Activity_Two
{
// main method definition
public static void main(String[] args)
{
// Scanner class object
created
Scanner scan = new
Scanner(System.in);
System.out.println("Enter two
numbers");
// Accepts first number
int a = scan.nextInt();
// Accepts second number
int b = scan.nextInt();
// Checks if b is not divisible by
a or a is 0
// then not multiple
if((b % a !=
0) || a == 0)
System.out.println(b + " is not a multiple of " + a);
// Otherwise divisible and it is
multiple
else
System.out.println(b + " is a multiple of " + a);
// Close the scanner class
scan.close();
}// End of main method
}// End of class
Sample Output 1:
Enter two numbers
2
12
12 is a multiple of 2
Sample Output 2:
Enter two numbers
9
25
25 is not a multiple of 9