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

Need help creating a half arrow using loops in Java. This program outputs a down

ID: 3784756 • Letter: N

Question

Need help creating a half arrow using loops in Java.

This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.

(1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt)

(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)

(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)

(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)

Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:

Explanation / Answer


  
   public static void main(String args[])
   {
       Scanner s=new Scanner(System.in);
   System.out.print("Enter arrow base height:");
   int m=s.nextInt();
   System.out.print("Enter arrow base width:");
   int n=s.nextInt();
   System.out.print("Enter arrow head width:");
   int p=s.nextInt();
   for(int i=0;i<m;i++)
   {
       for(int j=0;j<n;j++)
       {
           System.out.print("*");
       }
       System.out.println();
   }
   for(int k=0;k<p;k++)
   {
       for(int l=k;l<p;l++)
       {
           System.out.print("*");
       }
       System.out.println();
   }
  
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote