Skip to main content

Posts

Showing posts with the label 8. Write a Java program to count total number of notes in given amount.

ads1

8. Write a Java program to count total number of notes in given amount.

  8.Write a Java program to count total number of notes in given amount. Static   Solution  :- class notes {     public static void main(String args[])     {     int amount =1007;         int note2000, note500,note200,note100,note50,note20,note10,note5,note2,note1;         note2000=note500=note200=note100=note50=note20=note10=note5=note2=note1=0;         if (amount >=2000)     {         note2000 = amount/2000;         amount = amount - note2000 * 2000;     }     if (amount >=500)     {         note500 = amount/500;         amount = amount - note500 * 500;     }         if (amount >=200)     {         note200 = amount/200;         amount = amount - note200 * 200;     }     if (amount >=100)     {         note100 = amount/100;         amount = amount - note100 * 100;     }     if (amount >=50)     {         note50 = amount/50;         amount = amount - note50 * 50;     }     if (amount >=20)     {         note20 = amount/20;         amount = amount - note20 * 20;

ads2