Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nilai;
- import java.util.Scanner;
- public class Nilai {
- public static void main(String[] args) {
- Scanner masukan = new Scanner(System.in);
- int bil1, bil2, bil3;
- System.out.println("Program menjumlahkan 2 bilangan");
- System.out.print("Masukan angka pertama = ");
- bil1 = masukan.nextInt();
- System.out.print("Masukan angka kedua = ");
- bil2 = masukan.nextInt();
- System.out.print("Masukan angka ketiga = ");
- bil3 = masukan.nextInt();
- System.out.println();
- System.out.println("Nilai Terbesar adalah "+(terbesar(bil1,bil2,bil3)));
- System.out.println("Nilai Terkecil adalah "+(terkecil(bil1,bil2,bil3)));
- }
- private static int terbesar(int a, int b, int c){
- //@AUTHOR IRFAN
- //jgn pernah hapus credit
- int maks;
- maks = (a > b)?a:b;
- maks = (maks > c)?maks:c;
- return maks;
- }
- private static int terkecil(int a, int b, int c){
- //jgn pernah hapus credit
- int mini;
- mini = (b > a)?a:b;
- mini = (c > mini)?mini:c;
- return mini;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement