JAVA: K-shaped pattern using symbols | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JAVA: K-shaped pattern using symbols

in this code the user inputs a height (number of rows) and a symbol to create the K shaped pattern. But there's a condition: if the user inputs an odd number; the middle row will have a *single* symbol (not two beside each other), and if the user inputs an even number, there won't be a middle symbol. My code displays two symbols in the middle row. How do I correct it? https://code.sololearn.com/cFa524ERjAFS

5th Dec 2021, 7:41 PM
Salma D. Elabsi
Salma D. Elabsi - avatar
1 Answer
+ 3
Try use if (k==count && k!=0){ Line no: 24
5th Dec 2021, 7:57 PM
Jayakrishna 🇮🇳