2012420062, Yudha S.P, Tugas 12 (mencari elemen min-max), Semester 3

2012420062, Yudha S.P, Tugas 12 (mencari elemen min-max), Semester 3


import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
public class MinMax {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        String nilai = JOptionPane.showInputDialog(null, "Input Bilangan pakek koma");
String []semt=nilai.split(",");
int k=0;
int max=0;
int minim=Integer.parseInt(semt[0]);
int index=0;

while(k<semt.length){
   
    if (max>Integer.parseInt(semt[index])) {
        k++;
        index++;
    }else{
        max=Integer.parseInt(semt[index]);
        k++;
        index++;
    }
}
        System.out.println("nilai terbesar dari "+nilai+" adalah "+max);
        k=0;
        index=0;
       
        while(k<semt.length){
            if (minim<Integer.parseInt(semt[index])) {
                k++;
                index++;
               
            }else {
                minim=Integer.parseInt(semt[index]);
                k++;
                index++;
            }
        }
        System.out.println("Nilai terkecil dari "+nilai+" adalah "+minim);
           
        }
    }
   







share this article to: Facebook Twitter Google+ Linkedin Technorati Digg
Posted by arek informatika, Published at 14.09 and have 1 komentar

1 komentar:

  1. Borgata to hold opening of poker room at its Borgata Hotel Casino
    On 익산 출장샵 Tuesday, the 세종특별자치 출장안마 casino will have seven poker tables and nine 포항 출장마사지 live 사천 출장샵 poker rooms on the Borgata property. 성남 출장샵 The property is also

    BalasHapus