Print the following pattern using JAVA
*
*#
*#*
*#*#
Answers
Answered by
0
public class pattern
{
public static void main (String args[])
{
System.out.println("*");
System.out.println("*#");
System.out.println("*#*");
System.out.println("*#*#");
}
}
Here ends your program. I hope it helps!!!!!
Answered by
1
Question:-
Write a program in Java to print the following pattern.
*
*#
*#*
*#*#
Program:-
Here is your program in Java.
import java.util.*;
class Pattern
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows for the pattern: ");
int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(j%2==1)
System.out.print("* ");
else
System.out.print("# ");
}
System.out.println();
}
}
}
Similar questions
Hindi,
7 months ago
Environmental Sciences,
1 year ago
Science,
1 year ago
Chemistry,
1 year ago
Math,
1 year ago