+ 1
Write a progran in java:
to accept the amount of money to be withdrawn from a bank and find out the number of notes of each denomination to be given by the bank if the bank offers the following denominations of notes: Rs. 500, Rs. 100, Rs. 50, Rs. 20, Rs.10, Rs. 5, Rs. 2, Rs. 1.
7 Antworten
+ 1
ok 👍 I'll try it too😊 thank you so much ☺☺
0
thank you so much for helping me out😊👍 I'll try to write the code & then let I'll let you know☺
0
import java.util.*;
public class Program2
{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a[]={500,100,50,20,10,5,2};
System.out.println("Enter amount to be withdrawn");
int amt=in.nextInt();
int m=0;
int n; n=amt;
for(int i=0; i<7;i++)
{
if(amt>=a[i])
{
m=amt/a[i];
amt=amt%a[i];
System.out.println(a[i]+ " = " +m);
}
}
}
}
I've written the code and executed it..took me some time but it works!! I've done it with arrays though