Jenna Stevens
Jenna Stevens

Reputation: 1

For loop not printing user input

Need some expert advice. First here is my code:

public static void shapes ( ) {

    System.out.print("Enter the desired width:");
    int  dWidth = CONSOLE.nextInt( );

    for (int k = 0; k<dWidth; k++);
     System.out.print(" __   ");
}

My question is: When I enter a user number such as "3" when prompted my code only prints one of the __ when I want it to print the number specified. I can't for the life of me figure it out.

My ultimate goal is to have a program print the following (for a class I'm taking) by a user specified height

 __      __      __      __
/    \__/    \__/    \__/    \_
\__/    \__/    \__/    \__/
/    \__/    \__/    \__/    \_
\__/    \__/    \__/    \__/  
/    \__/    \__/    \__/    \_
\__/    \__/    \__/    \__/

Sorry it's so sloppy. I am sending this from my phone in a lab because it's due tonight and I'm baffled by the entire thing.

I'm an English major so this is not my forte :( The shapes are supposed to be diamonds

Upvotes: 0

Views: 53

Answers (1)

yeti
yeti

Reputation: 21

You have a ";" at the end of the for line. So it's actually a for loop that does nothing, and print once.

Upvotes: 2

Related Questions