1 lembaran ratusan ribu
2 lembaran puluhan ribu
3 lembaran ribuan
4 lembaran ratusan
5 lembaran puluhan
6 lembaran satuan
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Scanner;
public class Lembaran {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int angka, d1, d2, d3, d4, d5, d6, v, w, x, y, z;
DataInputStream in = new DataInputStream (System.in);
//nilai awal
angka=0;
//menerima nilai angka
try{
System.out.print("Masukkan angka : ");
angka=Integer.parseInt(in.readLine());
}
catch (IOException err) {}
//memisahkan digit
d1=angka/100000;
v=angka%100000;
d2=v/10000;
w=v%10000;
d3=w/1000;
x=w%1000;
d4=x/100;
y=x%100;
d5=y/10;
z=y%10;
d6=z;
//menampilkan hasilnya
System.out.printf("%d lembar ratusan ribu\n", d1);
System.out.printf("%d lembar puluhan ribu\n",d2);
System.out.printf("%d lembar ribuan\n",d3);
System.out.printf("%d lembar ratusan\n",d4);
System.out.printf("%d lembar puluhan\n",d5);
System.out.printf("%d lembar satuan\n",d6);
}
}
import java.io.IOException;
import java.util.Scanner;
public class Lembaran {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int angka, d1, d2, d3, d4, d5, d6, v, w, x, y, z;
DataInputStream in = new DataInputStream (System.in);
//nilai awal
angka=0;
//menerima nilai angka
try{
System.out.print("Masukkan angka : ");
angka=Integer.parseInt(in.readLine());
}
catch (IOException err) {}
//memisahkan digit
d1=angka/100000;
v=angka%100000;
d2=v/10000;
w=v%10000;
d3=w/1000;
x=w%1000;
d4=x/100;
y=x%100;
d5=y/10;
z=y%10;
d6=z;
//menampilkan hasilnya
System.out.printf("%d lembar ratusan ribu\n", d1);
System.out.printf("%d lembar puluhan ribu\n",d2);
System.out.printf("%d lembar ribuan\n",d3);
System.out.printf("%d lembar ratusan\n",d4);
System.out.printf("%d lembar puluhan\n",d5);
System.out.printf("%d lembar satuan\n",d6);
}
}
Hasilnya
--------------------Configuration:
<Default>--------------------
Masukkan angka : 2
0 lembar ratusan ribu
0 lembar puluhan ribu
0 lembar ribuan
0 lembar ratusan
0 lembar puluhan
2 lembar satuan
Process completed.
Download selengkapnya disini
No comments:
Post a Comment