Java Program to Print Exponentially Increased Star Pattern

Write a Java Program to print exponentially increased star pattern using for loop. It uses nested for loops, where the first for loop iterates from zero to given rows. Then, the Java nested loop iterate from 1 to power of i value for each iteration to print the exponentially increased star pattern.

package ShapePrograms;

import java.util.Scanner;

public class ExponentiallyIncrease1 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Exponentially Increased Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Exponentially Increased Rectangle Star Pattern");
		
		for (int i = 0; i < rows; i++ ) 
		{
			for (int j = 1 ; j <= Math.pow(2, i); j++ ) 
			{
				System.out.print("*");
			}
			System.out.println();
		}
	}
}
Java Program to Print Exponentially Increased Star Pattern 1

In this Java exponentially increased star pattern program, we replaced the for loop with a while loop.

package ShapePrograms;

import java.util.Scanner;

public class ExponentiallyIncrease2 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Exponentially Increased Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Exponentially Increased Rectangle Star Pattern");
		
		int i = 0, j;
		while( i < rows) 
		{
			j = 1 ;
			while ( j <= Math.pow(2, i) ) 
			{
				System.out.print("*");
				j++;
			}
			System.out.println();
			i++ ;
		}
	}
}
Enter Exponentially Increased Pattern Rows = 7
Printing Exponentially Increased Rectangle Star Pattern
*
**
****
********
****************
********************************
****************************************************************

Java Program to Print Exponentially Increased Star Pattern using do while loop

package ShapePrograms;

import java.util.Scanner;

public class ExponentiallyIncrease3 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		int i = 0, j;
		
		System.out.print("Enter Exponentially Increased Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Exponentially Increased Rectangle Star Pattern");
	
		do
		{
			j = 1 ;
			do
			{
				System.out.print("*");
			} while ( ++j <= Math.pow(2, i) );
			System.out.println();
		} while( ++i < rows) ;
	}
}
Enter Exponentially Increased Pattern Rows = 4
Printing Exponentially Increased Rectangle Star Pattern
*
**
****
********

In this Java example, the ExponentiallyIncreasedPattern function prints the exponentially increased pattern of a given symbol.

package ShapePrograms;

import java.util.Scanner;

public class ExponentiallyIncrease4 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Exponentially Increased Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.print("Enter Character for Exponentially Increased Pattern = ");
		char ch = sc.next().charAt(0);
		
		System.out.println("Printing Exponentially Increased Rectangle Star Pattern");
		ExponentiallyIncreasedPattern(rows, ch);
		
	}
	
	public static void ExponentiallyIncreasedPattern(int rows, char ch) {
		for (int i = 0; i < rows; i++ ) 
		{
			for (int j = 1 ; j <= Math.pow(2, i); j++ ) 
			{
				System.out.print(ch);
			}
			System.out.println();
		}
	}
}
Enter Exponentially Increased Pattern Rows = 7
Enter Character for Exponentially Increased Pattern = #
Printing Exponentially Increased Rectangle Star Pattern
#
##
####
########
################
################################
################################################################