Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chapt7ex4;
- import java.util.Scanner;
- public class Chapt7Ex4 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- addSpaces();
- }
- public static void drawBar(int i) {
- for (int k = 1; k <= i + 1; k++) {
- System.out.print(" *");
- }
- System.out.print("\n");
- }
- public static void addSpaces() {
- int size;
- Scanner input = new Scanner(System.in);
- System.out.print("\nEnter width: ");
- size = input.nextInt();
- for (int i = 0; i < size; i++) {
- for (int j = size; j > i; j--) {
- System.out.print(" ");
- }
- drawBar(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment