Begin typing your search above and press return to search. Press Esc to cancel.

Jawaban Tugas Akhir Modul 3 Urut Nilai



JAWABAN TA MODUL 3 (URUT NILAI)

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

package urutnilai;

/**
 *
 * @author Azharuddin
 */
import java.util.*;

class Perubahan {
    int x=0, y=0, z=0, o=0;
        public void uruttan(){
        Scanner sc = new Scanner (System.in);
        System.out.println ("Masukkan Bilangan Yang Anda Inginkan ");
        System.out.print("bilangan a = ");
        x = sc.nextInt();
        System.out.print("bilangan b = ");
        y = sc.nextInt();
        System.out.print("bilangan c = ");
        z = sc.nextInt();
        System.out.print("bilangan d = ");
        o = sc.nextInt();


    if (x> y ) {
            int temp = x;
             x = y;
             y = temp; }
        if (x > z) {
            int temp = x;
             x = z;
             z = temp; }
        if (x > o ) {
            int temp = x;
             x = o;
             o = temp; }
        if (y > z ) {
            int temp = y;
             y = z;
             z = temp;
             }
        if (y > o ) {
            int temp = y;
             y = o;
             o = temp;
             }
        if (z > o ) {
            int temp = z;
             z = o;
             o = temp;
            }

        System.out.println ("Terbesar = " + o);
        System.out.println ("Terkecil = " + x );
        System.out.println ("urutan nilai =" + x+","+y+","+z+","+o);
    }
}



    /**
     * @param args the command line arguments
     */
class UrutNilai {
    public static void main(String[] args) {
        // TODO code application logic here
        Perubahan P = new Perubahan ();
        P.uruttan();
    }

}

SEMOGA BERMANFAAT

TERIMAH KASIH TELAH MENGUNJUNGI APOTIK-ILMU

    No comments:

    Post a Comment