Tuesday, March 25, 2014

Contoh Program Menentukan Nilai Tertinggi

berikut contoh program untuk menentukan nilai tertinggi dari suatu bilangan
public class testmax{

 public static void main(String[]args){
  int i = 5;
  int j = 2;
  int k = max(i , j);

  System.out.println("the maximum betwen "+i+ " and "+j+" is "+k);

 }

public static int max(int num1, int num2){
  int result;
  if(num1 > num2)
   result = num1;
  else
   result = num2;

  return result;

 }
}

No comments:

Post a Comment