Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I would like some assistance with this Funtion from the describe information: Q:

ID: 3787264 • Letter: I

Question

I would like some assistance with this Funtion from the describe information:

Q: Function Design Recipe Following the Function Design Recipe, write a function that satisfies this description: This function returns a string containing a given word repeated a given number of times. For example, someone should be able to call the function to repeat "Marcia " three times and the function should return "Marcia Marcia Marcia ", or call the function to repeat "Buffalo " eight times and have it return "Buffalo Buffalo Buffalo Buffalo Buffalo Buffalo Buffalo Buffalo ".

Explanation / Answer

I am assuming that you are expecting answer in any programming language. I am using Java.

This code accepts the string and an integer and prints the string depending on value of an integer.

public class StringPrint {


   public void printString(String str,int num){
       for(int i=0;i<num;i++){
       System.out.print(str+" ");
   }
   }
  
   public static void main(String[] args) {
      
       int a;
   String s;
     
   Scanner in = new Scanner(System.in);
     
   System.out.println("Enter a string");
   s = in.nextLine();
     
   System.out.println("Enter an integer");
   a = in.nextInt();
  
   StringPrint stringPrint=new StringPrint();
   stringPrint.printString(s,a);

   }

}