Hermantos Share

Berbagi semua tips atau cara yang ada dalam satu blog hermantos share. Everything is there. Let's get it.

Create Pyramid with Java Programming

Java is one of the popular programming language after the Visual Basic programming language. The programming language is widely used by programmers in making a wide range applications that support the needs of the users of mobile phones that are Java based. The Java programming language itself is usually made with the script and the help application that support. Application to make Java Programs there are several types. Program supporters include JQreator/Notepad ++, Java/JDK. Such applications have their respective functions are : Notepad/JQreator is used us an application to the process of typing the script for the program with the language used is Java. While the Java/JDK is a Java application that support java script to compile that has been created. For example, in this description, we will create a stand-alone Java program that is making Pyramid with a Java program. How to make it pretty easy and simple. In the Pyramid in Java Program.

Create Pyramid with Java Programming :
To make it, you can use the Java code below.
public class Piramid
{
public static void main (String [] args)
{
int tinggi;
System.out.print("High : ");
tinggi = Integer.parseInt(System.console().readLine());
for(int i = 0; i < tinggi; i++)
{
System.out.println("");
for(int j = 0; j < i; j++)
System.out.print(" ");
for(int j = tinggi; j > i; j--)
System.out.print("*");
for(int j = tinggi - 1; j > i; j--)
System.out.print("*");
}
System.out.println("");
}
}
To see the result, then you need to run it by way of compiling via CMD with the way :

  • Open CMD ( Command Prompt ).
  • Then select the location of the java file you saved earlier.
  • The type the command : javac Piramid.java and then press enter. Then do it again in a way compile : java Piramid and press enter.
  • Then it would appear the words. Enter the Height you want and press enter.
  • The Pyramid display will appear as below.

Note :
  • In naming the file must be in the class of equate the program.
Happy Coding. Thanks :)

0 Komentar untuk "Create Pyramid with Java Programming"