Skip to content

Instantly share code, notes, and snippets.

@ardianta
Created October 16, 2015 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ardianta/6cbbb9a524d779ba5694 to your computer and use it in GitHub Desktop.
Save ardianta/6cbbb9a524d779ba5694 to your computer and use it in GitHub Desktop.
Program menghitung luas segitiga
package pertemuan2;
import java.util.Scanner;
public class LuasSegitia {
public static void main(String[] args) {
// deklarasi
Double luas;
int alas, tinggi;
// mebuat scanner baru
Scanner baca = new Scanner(System.in);
// Input
System.out.println("== Program hitung luas Segitiga ==");
System.out.print("Input alas: ");
alas = baca.nextInt();
System.out.print("Input tinggi: ");
tinggi = baca.nextInt();
// proses
luas = Double.valueOf((alas * tinggi) / 2);
// output
System.out.println("Luas = " + luas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment