In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..
import java.io.*;
class Javaexcercise
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int Rs[]={1000,500,100,50,20,10,5,2,1};
System.out.print("Enter any Amount : ");
int amount=Integer.parseInt(br.readLine());
int copy=amount;
int totalNotes=0,count=0;
System.out.println("\nRs OMINATIONS : \n");
for(int i=0;i<9;i++)
{
// counting number of notes.
count=amount/Rs[i];
if(count!=0)
{
System.out.println(Rs[i]+"\tx\t"+count+"\t= "+Rs[i]*count);
}
totalNotes=totalNotes+count;
amount=amount%Rs[i];
}
System.out.println("--------------------------------");
// printing the total amount
System.out.println("TOTAL\t\t\t= "+copy);
System.out.println("--------------------------------");
// printing the total number of notes
System.out.println("Total Number of Notes\t= "+totalNotes);
}
}
In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..
Result:
Enter any Amount : 5015
Rs OMINATIONS :
1000 X 5 = 5000
10 X 1 = 10
5 X 1 = 5
--------------------------------------------------
TOTAL = 5015
--------------------------------------------------
Total Number of Notes = 7
need an explanation for this answer? contact us directly to get an explanation for this answer