public class Triangle {public static void main (string[] args) {a ();//print positive isosceles triangle B ();//print Inverted isosceles triangle C ();//print straight edge left upright angle triangle d ();//Print Straight Edge on Right angle triangle E (); Print straight edge on left inverted right angle triangle f (); Print straight edge on right inverted triangle g (); Print bottom edge left obtuse angle triangle H (); Print bottom Right angle triangle}/** * Function: Print positive isosceles triangle */public static void A () {System.out.println ("Print positive isosceles triangle"); int i, j;for (i=1;i<=5;i++) { for (j=5;j>i;j--) {System.out.print ("");} for (j=0;j<i*2-1;j++) {System.out.print ("*");} System.out.println ();}} /** * Print inverted isosceles triangle */public static void B () {System.out.println ("Print inverted isosceles triangle"), int i, J; for (i=1;i<=5;i++) {for (j=1;j<i;j++) {System.out.print ("");} for (j=10;j>i*2-1;j--) {System.out.print ("*");} System.out.println ();}} /** * Print straight edge on left upright angle triangle */public static void C () {System.out.println ("Print straight edge on left upright angle triangle"); int i, J; for (i=1;i<=5;i++) {for (j=0;j <i;j++) {System.out.print ("*");} System.out.println ();}} /** * Print straight edge on right angle triangle */public static void D () {System.out.println ("Print straight edge on Right angle triangle"); int i, j;for (i=1;i<=5;i++) {for (j=5;j >i;j--) {System.out.print ("");} for (j=0;j<i;j++) {System.out.print ("*");}system.out.println ();}} /** * Print straight edge on left inverted right angle triangle */public static void E () {System.out.println ("Print straight edge on left inverted triangle"); int i, j;for (i=1;i<=5;i++) {for (j=5;j >=i;j--) {System.out.print ("*");} System.out.println ();}} /** * Print straight edge on right inverted triangle */public static void F () {System.out.println ("Print straight edge right inverted triangle"); int i, j;for (i=1;i<=5;i++) {for (j=1;j <i;j++) {System.out.print ("");} for (j=5;j>=i;j--) {System.out.print ("*");} System.out.println ();}} /** * Print bottom edge left obtuse angle triangle */public static void G () {System.out.println ("Print bottom edge left obtuse angle triangle"); int I, J; for (i=1;i<=5;i++) {for (j=0;j<i;j++) {System.out.print ("*"); } System.out.println (); } for (i=1;i<5;i++) {for (j=5;j>i;j--) {System.out.print ("*"); } System.out.println (); }}/** * Print bottom right angle triangle */public static void H () {System.out.print ("Print bottom Right angle triangle"); int i,j; for (i=0;i<=5;i++) {for (j=5;j>i;j--) {System.out.print (""); } for (j=0;j<i;j++) {System.out.print ("*"); } SystEm.out.println (); } for (i=1;i<5;i++) {for (j=0;j<i;j++) {System.out.print (""); } for (j=5;j>i;j--) {System.out.print ("*"); } System.out.println (); } }}
Java Console print Triangle area