Page 411 - Computer science 868 Class 12
P. 411

The output of the preceding program is as follows:




















                  Program 5      A bank intends to design a program to display the denomination of an input amount, upto 5 digits.
                                 The available denomination with the bank are of rupees 2000, 500, 200, 100, 50, 20, 10, 5, 2 and
                                 1. Design a program to accept the amount from the user and display the break-up in descending
                                 order of denomination. (i.e., preference should be  given to the highest denomination available)
                                 along with the total number of notes. [Note: Only the denomination used should be displayed].
                                 Also print the amount in words according to the digits.           [ISC Practical 2010]
                                 Example:
                                 INPUT: 14856
                                 OUTPUT:
                                 ONE FOUR EIGHT FIVE SIX
                                 DENOMINATION :
                                 2000 * 7 = 14000
                                 500 * 1 = 500
                                 200 * 1 = 200
                                 100 * 1 = 100
                                 50 * 1 = 50
                                 5 * 1 = 5
                                 1 * 1 = 1
                                 TOTAL = 14856
                                 TOTAL NUMBER OF NOTES = 13
                   1          import java.util.*;

                   2          class Note

                   3          { int amt;
                   4               String note[]={"ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT", "NINE"};
                   5              int d[]={2000,500,200,100,50,20,10,5,2,1};

                   6              void accept() // input amount
                   7              { Scanner sc=new Scanner(System.in);

                   8                  System.out.println("Enter amount");
                   9                  amt=sc.nextInt();

                  10              }




                                                                                                                       409
                                                                                                           Recursion   409
   406   407   408   409   410   411   412   413   414   415   416