JAVA - How To Create A Program To Print Trapezoid Star Program In Java
In This Java Code We Will See How To Make A Program To Print A Trapezoid Using For Loop In Java Programming Language.
Source Code:
package javaapp;
public class Woirk {
public static void main(String[] args){
int k = 10;//number of spaces
int d = 20;//number of stars
//loop for 10 lines
for(int i = 0; i < 10; i++){
for(int l = k; l > 1; l--){
System.out.print(" ");//two spaces
}
//loop for d stars
for(int j = 0; j < d; j++){
System.out.print("*");
}
System.out.println();
k--;//discriminate the number of spaces
d = d+4;//increment the number of stars
}
}
}
//////////OUTPUT:
Source Code:
package javaapp;
public class Woirk {
public static void main(String[] args){
int k = 10;//number of spaces
int d = 20;//number of stars
//loop for 10 lines
for(int i = 0; i < 10; i++){
for(int l = k; l > 1; l--){
System.out.print(" ");//two spaces
}
//loop for d stars
for(int j = 0; j < d; j++){
System.out.print("*");
}
System.out.println();
k--;//discriminate the number of spaces
d = d+4;//increment the number of stars
}
}
}
//////////OUTPUT:
Trapezoid Star Program In Java |
Bagikan
JAVA - How To Create A Trapezoid Star Program In Java
4/
5
Oleh
insurance