Write a program to accept the amount from the user and display the
breakup in descending order of denomination alongwith the total number
of notes.
Answers
Hey,
This is my answer
I used Blue j
It works perfectly fine...
Question:
Write a program to accept the amount from the user and display the break-up in descending order of denomination along with the total number of notes
Program:
import java.util.*;
class amount
{
void main ()
{
Scanner z = new Scanner(System.in);
System.out.println("Enter number of units");
int a = z.nextInt();
int b = a/2000;
int c = a%2000;
int d = c/500;
int e = c%500;
int f = e/200;
int g = e%200;
int h = g/100;
int i = g%100;
int j = i/50;
int k = i%50;
int l = k/20;
int m = k%20;
int n = m/10;
int o = m%10;
int p = o/5;
int q = o%5;
int r = q/2;
int s = q%2;
int t = s/1;
int u = s%1;
System.out.println ("The number of ₹2000 notes " + b);
System.out.println ("The number of ₹500 notes " + d);
System.out.println ("The number of ₹200 notes " + f);
System.out.println ("The number of ₹100 notes " + h);
System.out.println ("The number of ₹50 notes " + j);
System.out.println ("The number of ₹20 notes " + l);
System.out.println ("The number of ₹10 notes " + n);
System.out.println ("The number of ₹5 notes " + p);
System.out.println ("The number of ₹2 notes " + r);
System.out.println ("The number of ₹1 notes " + t);
int v = b+d+f+h+j+l+n+p+r+t;
System.out.println ("Total number of notes is " + v);
}
}
Output:
Enter number of units
647
The number of ₹2000 notes 0
The number of ₹500 notes 1
The number of ₹200 notes 0
The number of ₹100 notes 1
The number of ₹50 notes 0
The number of ₹20 notes 2
The number of ₹10 notes 0
The number of ₹5 notes 1
The number of ₹2 notes 1
The number of ₹1 notes 0
Total number of notes is 6
Hope this helps.
Pls mark me brainliest!!!