Advertisement
irfanamir

nilai.java

Apr 16th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package nilai;
  2. import java.util.Scanner;
  3. public class Nilai {
  4.  
  5. public static void main(String[] args) {
  6. Scanner masukan = new Scanner(System.in);
  7. int bil1, bil2, bil3;
  8. System.out.println("Program menjumlahkan 2 bilangan");
  9. System.out.print("Masukan angka pertama = ");
  10. bil1 = masukan.nextInt();
  11. System.out.print("Masukan angka kedua = ");
  12. bil2 = masukan.nextInt();
  13. System.out.print("Masukan angka ketiga = ");
  14. bil3 = masukan.nextInt();
  15. System.out.println();
  16. System.out.println("Nilai Terbesar adalah "+(terbesar(bil1,bil2,bil3)));
  17. System.out.println("Nilai Terkecil adalah "+(terkecil(bil1,bil2,bil3)));
  18. }
  19.  
  20. private static int terbesar(int a, int b, int c){
  21. //@AUTHOR IRFAN
  22. //jgn pernah hapus credit
  23. int maks;
  24. maks = (a > b)?a:b;
  25. maks = (maks > c)?maks:c;
  26. return maks;
  27. }
  28.  
  29. private static int terkecil(int a, int b, int c){
  30. //jgn pernah hapus credit
  31. int mini;
  32. mini = (b > a)?a:b;
  33. mini = (c > mini)?mini:c;
  34. return mini;
  35.  
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement