Ques - Write a java program for the following pattern of 'F' :
* * * *
*
*
* * * *
*
*
*
PROGRAM :
import java.util.Scanner;
public class PatternF
{
public static void main(String[] args)
{
System.out.print("Enter the number of rows : ");
public class PatternF
{
public static void main(String[] args)
{
System.out.print("Enter the number of rows : ");
Scanner scan=new Scanner(System.in);
System.out.println();
int n=scan.nextInt();
for (int i=0;i<n ;i++ )
{
for (int j=0;j<=n/2 ;j++ )
{
if (i==0||i==n/2||j==0)
{
System.out.print("* ");
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
}
}
/*
Output:
Enter the number of rows : 7
* * * *
*
*
* * * *
*
*
*
*/
Related post: