Showing posts with label money bills denomination counter in java. Show all posts
Showing posts with label money bills denomination counter in java. Show all posts

Sunday, June 28, 2015

Money Bills Denomination Counter in Java

A simple program that I wrote in Java that will count how many money bills in a given amount of money. It uses % or modulo operator of Java to achieve its results.The code is very simple but it uses already the concepts of object oriented programming.

I hope you will find my work  useful in a sense the logic of programming is also applied in this simple program.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

import java.util.Scanner;


class bills{
    public static int count_bills(int amount)
    {
   int solve_thousand=0,solve_five=0,solve_two=0,solve_one=0;
   int remainder_thousand=0,remainder_five=0;
   int remainder_two=0,remainder_one=0;

   solve_thousand =(amount/ 1000);
   remainder_thousand = solve_thousand % 1000;

   solve_five =(amount/ 500);
   remainder_five = solve_five % 500;

   solve_two =(amount/ 200);
   remainder_two = solve_two % 200;

   solve_one =(amount/ 100);
   remainder_one= solve_one % 200;
   
   System.out.println("\n");
   System.out.println("Number of Php 1000 Bill(s) :=> " +  remainder_thousand);
   System.out.println("Number of Php 500  Bill(s) :=> " +  remainder_five);
   System.out.println("Number of Php 200  Bill(s) :=> " +  remainder_two);
   System.out.println("Number of Php 100  Bill(s) :=> " +  remainder_one);
   return 0;
   }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
  do
    {
    System.out.println();
    System.out.println("===== MONEY BILLS DENOMINATION COUNTER =====");
    System.out.println();
    System.out.print("Enter the Amount : Php  ");
    int amount = scan.nextInt();

    count_bills(amount);      
    System.out.println("\n");
    System.out.print("Do you Want To Continue (Y/N) :=> ");
    a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
     System.out.println("\n");
     System.out.println("\t ===== END OF PROGRAM ======");
     System.out.println("\n");
   }
  
  }  // End of Program