Advertisement
irfanamir

prak_402

Apr 16th, 2020
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package prak_402;
  2. import java.util.Scanner;
  3. public class Prak_402 {
  4.    
  5.     public static void main(String[] args) {
  6.         Scanner masukan = new Scanner(System.in);
  7.         int bil1, bil2, bil3;
  8.        
  9.         System.out.println("Program menjumlahkan 2 bilangan");
  10.         System.out.println("");
  11.         System.out.print("Masukkan bilangan 1 : ");
  12.         bil1=masukan.nextInt();
  13.         System.out.print("Masukkan bilangan 2 : ");
  14.         bil2=masukan.nextInt();
  15.         System.out.print("Masukkan bilangan 3 : ");
  16.         bil3=masukan.nextInt();
  17.         System.out.println("");
  18.         System.out.println("jumlah bil1+bil2 : "+(jumlah(bil1,bil2)));
  19.         System.out.println("jumlah bil2+bil3 : "+(jumlah(bil2,bil3)));
  20.         System.out.println("jumlah bil1+bil3 : "+(jumlah(bil1,bil3)));
  21.     }
  22.     private static int jumlah(int a, int b){
  23.         int hasil=a+b;
  24.         return hasil;
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement