Java Chapters

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

Structure of JAVA Programs - Overview
import java.util.Scanner;

public class Program 
{
    public static void main( String[] args ) 
    {
        int Amount;
        Scanner reader = new Scanner(System.in);
        
        System.out.print("Please Enter Amount for Withdraw : ");
        Amount = reader.nextInt();
        
        System.out.print("\n\nRequired notes of 100 is : " + Amount / 100);
        System.out.print("\nRequired notes of 50 is : " + (Amount % 100) / 50);
        System.out.print("\nRequired notes of 10 is : " + (((Amount % 100) % 50) / 10));
        System.out.print("\nAmount still remaining is : " + (((Amount % 100) % 50) % 10));
    }
}

Output :
Please Enter Amount for Withdraw : 1275

Required notes of 100 is : 12
Required notes of 50 is : 1
Required notes of 10 is : 2
Amount still remaining is : 5

Leave a comment
Recent Comments
No Comments