<!--
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);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.