Debug the code in the starter file so if 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 by 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(;
intb scan.nextInt();
if(b% a = 0 || a
OD
system.out.println(b + " is not a multiple of " + a);
else
system.out.println(b + is a multiple of " + a);
10
}
}

Respuesta :

Debugging a code involves finding and fixing the errors in a code.

The errors in the code are as follows:

  • Class name
  • Print statements
  • Variable declarations
  • Input statements
  • If condition

The class name

The class name of the program is U3_L5_Activity Two

A class name cannot contain space; instead you make use of an underscore.

So, the correct class name is: U3_L5_Activity_Two or U3_L5_ActivityTwo

The print statement

Java differentiates lower and upper case letters.

The print statements in the program begin with a small letter s. This is wrong

So, the correct statements are:

  • System.out.println("Enter two numbers");
  • System.out.println(b + " is a multiple of " + a);}
  • System.out.println(b + " is not a multiple of " + a);

The declaration and the input statements

Variables a and b were declared wrongly, and the input statements are also wrong.

The correct statements are:

  • int a = scan.nextInt();
  • int b = scan.nextInt();

The condition

The if condition is not properly formatted.

The correct statement is: iif(b%a == 0)

Hence, the correct code is:

import java.util.Scanner;

public class Main{

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){

       System.out.println(b + " is a multiple of " + a);}

   else{

       System.out.println(b + " is not a multiple of " + a);

   }

}

}

Read more about debugging at:

https://brainly.com/question/23527739