Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DrawHalfArrow {
- public static void main(String[] args) {
- Scanner scnr = new Scanner(System.in);
- int arrowBaseHeight = 0;
- int arrowBaseWidth = 0;
- int arrowHeadWidth = 0;
- // int i = 0;
- System.out.println("Enter arrow base height: ");
- arrowBaseHeight = scnr.nextInt();
- System.out.println("Enter arrow base width: ");
- arrowBaseWidth = scnr.nextInt();
- System.out.println("Enter arrow head width: ");
- arrowHeadWidth = scnr.nextInt();
- while (arrowHeadWidth <= arrowBaseWidth) {
- System.out.println("Enter arrow head width: ");
- arrowHeadWidth = scnr.nextInt();
- }
- // printing arrow base
- for (int h = 0; h < arrowBaseHeight; ++h) {
- // printing single line - every line is the same
- for (int w = 0; w < arrowBaseWidth; w++)
- System.out.print("*");
- // finishing line
- System.out.println();
- }
- // printing arrow head
- // starting with provided width and decreasing it with every iteration
- for (int a = arrowHeadWidth; a > 0; a--) {
- // printing single line - now every line is different
- // you have to count how many asterisks you are printing
- for (int i = 0; i < a; i++)
- System.out.print("*");
- // finishing line
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement