Hi I am having some difficulties with this problem, I am not sure why my code is giving an incorrect output.
Hi I am having some difficulties with this problem, I am not sure why my code is giving an incorrect output.
Here is the provided code:
import java.util.Scanner; public class DrawHalfArrow { |
Here is my code:
import java.util.Scanner;
public class DrawHalfArrow { public static void main(String[] args) { //declare variables of integer type int baseHeight; int baseWidth; int headWidth;
//Scanner class object Scanner console=new Scanner(System.in);
//height, width and head width System.out.println("Enter arrow base height:"); baseHeight=Integer.parseInt(console.nextLine());
System.out.println("Enter arrow base width:"); baseWidth=Integer.parseInt(console.nextLine());
System.out.println("Enter arrow head width:"); headWidth=Integer.parseInt(console.nextLine());
//arrow tail for (int i = 0; i < baseHeight; i++) { for (int j = 0; j < baseWidth; j++) { System.out.printf("*"); } System.out.println(); } //print arrow head for (int i = headWidth; i>=1; i--) { for (int j = i; j >=1 ; j--) { System.out.print("*"); } System.out.println(); } } } |
Thanks!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images