4. Indian Currency

by venkatavineela

HTML

<!--

Problem 4:

Background:
At present, currency notes in India are issued in the denomination of Rs.5, Rs.10, Rs.20, Rs.50, Rs.100, Rs.500 and Rs.1000.
http://www.rbi.org.in/currency/faqs.html

Problem statement:
Write a program that will enable counting of money given in the form of Indian currency notes. The program must take a variable number of arguments. These arguments must be summed and the total must be displayed. For any input number that does not match a valid currency denomination, ignore the value and stop counting further, displaying the sum counted so far.

Examples:

Given an input of 10, 20, 100
When the code is executed
Then display 130

Given an input of 20, 50, 10, 20, 13, 500
When the code is executed
Then display 100

-->
<html>

<body id="body">

</body>
</html>
</html>

JavaScript

document.getElementById("body").onload=isDenominationValid;

function isDenominationValid(){
var res=0;
var total = 0;
var value;
do
{


 value =parseInt(prompt(`Total: Rs.${res}`, "Enter an amount: "));

if((value==5)||(value==10)||(value==20)||(value==50)||(value==100)||(value==500)||(value==1000))
{
  total=value;
  }
  else
  total=null;


res+=total;
}while(total!=null);

alert(res);
}