WILL GIVE BRAINLIEST, JAVA PROGRAMMING PLS HELP
Here is the prompt:
The code provided is intended to use a while loop to print the first 9 multiples of an integer entered by the user. For example if the user enters 5, the program should print the numbers 5, 10, 15.,... up to 45, one per line. Debug the code so it functions as described.
Here is the code:
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
int fac = 1;
while(fac < 9){
System.out.println(num*fac);
fac++;
System.out.println(num*fac);
}

}
}

Respuesta :

Answer:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       int num = scan.nextInt();

       int fac = 1;

       while(fac <= 9){

           System.out.println(num*fac);

           fac++;

       }  

   }

}

Explanation:

Hello, I tried out your program, and I just wanted to point out some little issues :)

You need to import the java.util.Scanner in order to use Scanners :)

Also, (not sure if you just didn't copy the stuff at the start) but you need the public class and the public static void main.

Last of all, since you're printing out all of the first 9 multiples, the 9th is included, so you use <= instead of <.

I have sent you the right code above ^^ :)

Please mark brainliest if this has helped you.

Debugging a code involves locating and fixing the errors/bugs in the code.

The error in the code is that, the following print statement is repeated twice

System.out.println(num*fac);

The correction is to remove the first appearance of

System.out.println(num*fac);

So, the corrected code is as follows

Scanner scan = new Scanner(System.in);

int num = scan.nextInt();

int fac = 1;

while(fac < 9){

System.out.println(num*fac);

fac++;

}

Read more about debugging at:

https://brainly.com/question/23527739