Currency Denomination

import java.io.*;
class Currency_Denomination
 {
     public static void main()throws IOException
     {
        InputStreamReader x=new InputStreamReader(System.in);
        BufferedReader y=new BufferedReader(x);
        int i,r,sum=0;
        System.out.println(“Enter currency amount”);
        int n=Integer.parseInt(y.readLine());
        int temp=n;
        int d[]={1000,500,100,50,20,10,5,2,1};
        String s[]={“Rs.1000″,”Rs.500″,”Rs.100″,”Rs.50″,”Rs.20″,”Rs.10″,”Rs.5″,”Rs.2″,”Re.1”};
        for(i=0;i<=8;i++)
        {
            r=n/d[i];
            System.out.println(s[i]+ “\tx\t”+r+”\t=\t”+d[i]*r);
            n=n%d[i];
            sum=sum+r;
        }
        System.out.println(“————————————–“);
        System.out.println(“\t\t”+sum+”\t\t”+temp);
        System.out.println(“————————————–“);
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s