JAVA Write code which takes a user input of a String and an integer. The code should print each letter of the String the number of times the user inputted in reverse order.

Sample run:

Input a String:
code
Input an integer:
3
eeedddoooccc

Respuesta :

Answer:

 Scanner sc= new Scanner(System.in);

   

  System.out.print("Input a String: ");  

  String str = sc.nextLine();  

   

  System.out.print("Input an integer: ");  

  int num = sc.nextInt();  

   

  for(int i=str.length()-1; i>=0; i--) {

      for(int j=0; j<num; j++) {

          System.out.print(str.charAt(i));

      }

  }

Explanation:

That should work just let me know!