Answers for "java program floyd's triangle"

1

Floyd's triangle star pattern in java

// Floyd's triangle star pattern in java
import java.util.Scanner;
public class FloydTriangleStars
{
   public static void main(String[] args) 
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the number of rows of floyd's triangle you want to print: ");
      int rows = sc.nextInt();
      System.out.println("Printing floyd's triangle with stars in java");
      for(int a = 1; a <= rows; a++)
      {
         for(int b = 1; b <= a; b++)
         {
            System.out.print("* ");
         }
         System.out.println();
      }
      sc.close();
   }
}
Posted by: Guest on February-18-2021
1

Java program to print Floyd's triangle

import java.util.Scanner;
public class PrintFloydsTriangle
{
   public static void main(String[] args)
   {
      int row, y, z, number = 1;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the number of rows of floyd's triangle you want to print: ");
      row = sc.nextInt();
      System.out.println("Floyd's Triangle: ");
      for(y = 1; y <= row; y++)
      {
         for(z = 1; z <= y; z++)
         {
            System.out.print(number + " ");
            number++;
         }
         System.out.println();
      }
      sc.close();
   }
}
Posted by: Guest on December-26-2020

Code answers related to "java program floyd's triangle"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language