Kamis, 03 Oktober 2013

struktur algoritma:

  1. masuk
  2. masukkan input s1
  3. masukkan input s2
  4. proses(masukkan rumus luas trapesium luas=1/2*jumlah sisi sejajar(s1+s2)*t
  5. cetak hasil luas
  6. selesai
flowchart:



















source code:

import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Lukman
 */
public class LuasTrapesium {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner trapesium=new Scanner(System.in);
       
     
        System.out.print("masukan nilai s1:    ");
        int s1=trapesium.nextInt();
        System.out.print("masukan nilai s2:    ");
        int s2=trapesium.nextInt();
        System.out.print("masukan nilai t:    ");
        int t=trapesium.nextInt();
       
        double lu= (s1+s2)*(t*0.5);
       
        System.out.print("maka luas trapesium adalah:"  +lu);
        // TODO code application logic here
    }
}

Tidak ada komentar:

Posting Komentar