
Hi,
I have to create a program which its output is:
and this what I did so far :
package symbols; import java.util.*; public class Symbols {
public static void main(String[] args) {
Scanner read = new Scanner (System.in);
int nline, count, countl, nspace= 0, i;
char symbol;
System.out.print(" how many lines you want to print? ");
nline= read.nextInt();
System.out.print("what is the symbol you want to use ");
symbol= read.next().charAt(0);
for (countl=1; countl<=nline; countl++){
System.out.print(symbol);
System.out.println();
for (count=1; count<=countl; count++)
System.out.print(symbol);}
}
}
but this is what I get:
I don't know why it keep giving me the last line twice !! what is the problem and who can I fix it ?

Here is a code that creates a triangle of the symbol.
import java.util.*;
public class Symbols {
public static void main(String[] args) {
Scanner read = new Scanner (System.in);
int nline, count, countl, nspace= 0, i;
char symbol;
System.out.print(" how many lines you want to print? ");
nline= read.nextInt();
System.out.print("what is the symbol you want to use: ");
symbol= read.next().charAt(0);
for (countl=1; countl<=nline; countl++){
System.out.println();
for(count=1; count<=countl; count++)
System.out.print(symbol);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.