Luas Trapesium menggunakan java (Fungsi dengan nilai balik)



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package luas.trapesium;

import java.util.Scanner;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner trapesium = new Scanner(System.in);
        int ab, cd, luas, nim;
        String nama;
       
        System.out.print ("Nama : ");
        nama=trapesium.nextLine();
       
        System.out.print ("NIM  : ");
        nim=trapesium.nextInt();
              
        System.out.print ("Masukan Alas : ");
        ab = trapesium.nextInt();
       
        System.out.print ("Masukan Sisi : ");
        cd = trapesium.nextInt();
       
        System.out.println("Hasilnya adalah  "+ luas(ab,cd));
    }
    static int luas(int ab,int cd){
        int luas =((ab*cd)/2);
        return luas;
    }

 }

Comments