Denomination of Notes

 

package textBookk01;

// Denomination of Notes

import java.util.Scanner;

public class DenominationNotes01 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter Amount :");

int amount = sc.nextInt();

int denomination[] = {2000,500,200,100};

int notecount[] = new int[denomination.length];

for(int i=0;i<denomination.length;i++) {

if(amount >=denomination[i]) {

notecount[i] = amount / denomination[i];

amount = amount % denomination[i];

}

}

System.out.println("Denomainton count :");

for(int i=0;i<denomination.length;i++) {

System.out.println(denomination[i]+ " * "+notecount[i]);

}

}

}


------------------------------------------------



for(int i=0;i<denomination.length;i++) {

    if(amount >=denomination[i]) {

    notecount[i] = amount / denomination[i];

    amount = amount % denomination[i];

}

here, notecount[i] = amount / denomination[i];

       notecount[i] = 2

         notecount[i] = 1

         notecount[i] = 1

         notecount[i] = 1


here,  amount = amount % denomination[i];

        amount = 800

        amount = 300

        amount = 100

        amount = 000

    



Comments