Denomination Of Notes Currency In Java Isc Icse CBSE

import java.util.*;
class Denomination{
    public static void main(){
     Scanner sc=new Scanner(System.in);
     int n,nn,c=0,s=0,i;
     int a[]={1000,500,100,50,20,10,5,2,1};
        System.out.println("Enter a multidigit no.");
         n=sc.nextInt();
         nn=n;
         if((n+"").length()>5){
             System.exit(1);
            }
            else{
            for(i=0;i<=8;i++){
                c=n/a[i];
                if(c!=0){
                System.out.println(a[i]+"  *  "+c+"      "+a[i]*c);
            }
                s+=c;
                n=n%a[i];
            }
        }
        System.out.println("Total  "+nn);
        System.out.println("Total no. of notes    "+s);
    }
}
        

Comments

Popular posts from this blog

Sort Boundary Elements Of A Matrix

Lucky Number In Java ISC

Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.