#Print words from user input in star pattern

1 messages · Page 1 of 1 (latest)

simple berry
#

I want to print the letters horizontally but when i removed the System.out.println.. it will print the way i want it but its a mess it cant print the exact shape of the letter

rare burrowBOT
#

<@&987246399047479336> please have a look, thanks.

rare burrowBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

pattern you want. Here's an example of how you can print the letters horizontally in a star pattern:

import java.util.Scanner;

public class StarPattern {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a word: ");
        String word = scanner.nextLine();

        for (int i = 0; i < word.length(); i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print(word.charAt(j) + " ");
            }
            System.out.println();
        }
    }
}

In this example, we use nested loops to iterate through each character of the input word and print them horizontally in a star pattern. The outer loop controls the number of rows, and the inner loop prints the characters up to the current row number.

For example, if the user enters "HELLO", the output will be:

H
H E
H E L
H E L L
H E L L O
lapis star
#

there are two print related methods print and println, if you choose the first the characters/strings are printed in same row but if you choose the second one it also prints a newline at the end thus new character/string would be printed on a different line.