0% found this document useful (0 votes)
28 views2 pages

Code Menghitung Pecahan Uang

The document is a Java code that calculates the number of banknotes needed for a given amount of money. It takes the amount of money as input, divides it by different denominations (100,000, 50,000, 20,000, 10,000, 5,000), calculates the number of banknotes for each denomination and prints the results.

Uploaded by

Noor Lailani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Code Menghitung Pecahan Uang

The document is a Java code that calculates the number of banknotes needed for a given amount of money. It takes the amount of money as input, divides it by different denominations (100,000, 50,000, 20,000, 10,000, 5,000), calculates the number of banknotes for each denomination and prints the results.

Uploaded by

Noor Lailani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Code Menghitung Pecahan Uang:

import java.util.Scanner;

public class menghitungLembarUang {


public static void main(String[] args) {
System.out.print ("Masukkan jumlah uang = ");

int uang, hitung, hitung1, hitung2, hitung3, hitung4, sisa, sisa1, sisa2, sisa3, sisa4;

Scanner keyboard = new Scanner (System.in);


uang = keyboard.nextInt();

hitung = uang / 100000;


sisa = uang % 100000;

hitung1 = sisa / 50000;


sisa1 = sisa % 50000;

hitung2 = sisa1 / 20000;


sisa2 = sisa1 % 20000;

hitung3 = sisa2 / 10000;


sisa3 = sisa2 % 10000;

hitung4 = sisa3 / 5000;


sisa4 = sisa3 % 5000;
System.out.println("100.000 ada " + hitung + " lembar");
System.out.println("50.000 ada " + hitung1 + " lembar");
System.out.println("20.000 ada " + hitung2 + " lembar");
System.out.println("10.000 ada " + hitung3 + " lembar");
System.out.println("5.000 ada " + hitung4 + " lembar");
System.out.println("Sisa uang = " + sisa4);

}
}

Hasil:

You might also like