Sunday 16 August 2015

A cashier has currency notes of denominations 10,50 and 100.If the amount to be withdrawn is the input through the keyboard in hundreads,WAP in java to find the total no of currency notes of each denomination the cashier will have to give to the withdrawer.

//Currency Denominations of 100,50 and 10

import java.util.Scanner;

class Currency {

public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter amount which can be denominated in 10:");
long a=sc.nextLong();

if(a<0 || a%10!=0)
System.out.println("Invalid Input");
else
{
System.out.println("Denominations of 100:"+(a/100));
a=a%100;
System.out.println("Denominations of 50:"+(a/50));
a=a%50;
System.out.println("Denominations of 10:"+(a/10));
}
}
}

No comments:

Post a Comment