Program Urut Angka Ascending & Descending [Java #5] - Haiqal MA

Post Top Ad

Responsive Ads Here

Program Urut Angka Ascending & Descending [Java #5]

Share This
Bagian kelima adalah program urut angka bahasa pemrograman Java.

import java.util.Scanner;

public class UrutAngka {

public static void main(String[] args) {
System.out.print("Masukkan Total Angka yang diurut: ");
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();

System.out.println("*******************");
System.out.println("1. Ascending ");
System.out.println("2. Descending ");
System.out.print("Masukkan Pilihan Anda [1-2] ?");
int pil = scan.nextInt();

int i;

switch(pil) {
case 1 :

for(i=1; i<=n; i++) {
System.out.print(i);
}
break;

case 2 :

for(i=n; i>0; i--) {
System.out.print(i);
}
break;
}
}
}



Jika masih bingung bisa lihat video tutorial dibawah ini ya 😁😁

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages