You are on page 1of 3

TUGAS BPL KADEK ANANTA SATRIADI 0915051023 1.

/* * Program Luas Segitiga * created by Ananta Satriadi */ package luassegitiga; import java.io.*; class Segitiga { public double Luas (double a, double t){ double hasil = a * t / 2; return(hasil); } } public class Main { public static void main(String[] args) { BufferedReader BR = new BufferedReader (new InputStreamReader(System.in)); System.out.print("Ukuran alas = "); String A = null; try { A = BR.readLine(); } catch (IOException io){ System.out.println(); } double a = Double.parseDouble(A); System.out.print("Ukuran tinggi = "); String T = null; try { T = BR.readLine(); } catch (IOException io){ System.out.println(); } double t = Double.parseDouble(T); Segitiga newSgt = new Segitiga (); double hasilLuas = newSgt.Luas(a, t); System.out.println("Luas segitiga = "+hasilLuas); } }

TUGAS BPL KADEK ANANTA SATRIADI 0915051023 2. /* * Program Tampil Genap * created by Ananta Satriadi */ package tampilgenap; import java.io.*; public class Main { public static void main(String[] args) { // TODO code application logic here System.out.print("Masukkan batas N : "); BufferedReader BR = new BufferedReader (new InputStreamReader (System.in)); String N = null; try { N = BR.readLine(); } catch (IOException io){ System.out.println(); } int n = Integer.parseInt(N); while (--n > 0 ) { if (n % 2 == 0){ System.out.print(n+" "); } } System.out.println(); } }

TUGAS BPL KADEK ANANTA SATRIADI 0915051023 3. /* * Program Menampilkan Segitiga Sama Sisi * created by Ananta Satriadi */ package segitiga; import java.io.*; public class Main { public static void main(String[] args) { System.out.print("Panjang Sisi = "); BufferedReader BR = new BufferedReader (new InputStreamReader (System.in)); String N = null; try { N = BR.readLine(); } catch (IOException io){ System.out.println(); } int n = Integer.parseInt(N); for (int i = 1 ; i <= n; i++){ for (int j = 1; j <= i ; j++){ System.out.print("*"); } System.out.println(); } } }

You might also like