0% found this document useful (0 votes)
22 views1 page

Printing Char Patterns

Uploaded by

adinrose06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Printing Char Patterns

Uploaded by

adinrose06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import java.util.

*;

class PrintingCharPatternUsingNestedLoop
{
int line;
char ch;

public PrintingCharPatternUsingNestedLoop()
{
line=0;
ch=0;
}

public void AssigningValToLineAndCh()


{
Scanner Sc = new Scanner(System.in);

System.out.println("ENTER VAL IN LINE");


line=Sc.nextInt();

System.out.println("ENTER VAL IN CH");


ch=Sc.next().charAt(0);
Sc.close();
}

public void PrintingCharacterPattern()


{
for(int i=1; i<=line; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print(ch);
ch++;

}
System.out.println();
}
}

public static void main(String args[])


{
PrintingCharPatternUsingNestedLoop obj = new
PrintingCharPatternUsingNestedLoop();

obj.AssigningValToLineAndCh();
obj.PrintingCharacterPattern();
}

You might also like