Please only code in Javascript I need help in making a progr
Please only code in Javascript.
I need help in making a program that has a cash register and inventory class. The user needs to be able to input which items they would like to buy and the quantity.
There needs to be a 30 % profit added to the cost to get the unit price.
multiply the unit price times the qauntity to get the subtotal.
compute a 6% sales tax on the subtotal to get the purchase total.
Subtract the qauntity of items bought and print remainder to screen
print subtotal, purchase total and unit price to the screen for the user....
Please answer this only using Javascript
Thanks
Solution
html:
<fieldset class=\"stock-control\">
<legend>Edit stock Amount</legend>
<label>ID:</label>
<input type=\"text\" id=\"txt-id\">
<label>Amount:</label>
<input type=\"text\" id=\"text-change\"><br />
<input type=\"button\" id=\"btn-add\" value=\"Add\">
<input type=\"button\" id=\"btn-sub\" value=\"subtract\">
<input type=\"button\" id=\"btn-set\" value=\"set\">
<br />
<label>In stock: </label><span id=\"Ib1-total\"></span>
</fieldset>
<fieldset class=\"stock-control\">
<legend>Edit stock Amount</legen>
<label>ID:</label>
<input type=\"text\" class=\"txt-id\".
<label>Amount:</label>
<input type=\"text\" class=\"txt-change\"><br/>
<input type=\"buttton\" class=\"btn-add\" value=\"Add\">
<input type=\"button\" class=\"btn-sub\" value=\"subtract\">
<input type=\"button\" class=\"btn-set\" value=\"Set\">
<br />
<label>In stock:</label><span class=\"2b1-total\"></span>
</fieldset>
javascript:
$(function(){
$(\'.stock-control\').each(function(){
var $control = $(this);
var $id = $control.find(\'.txt-id\');
var $amount = $control.find(\'.txt-amount\');
var $total = $control.find(\'.1b1-total\');
function RenderAmount(){
$total.text(stockRecorder.GetAmount($id.val()));
};
$(\'.btn-add\').click(function(){
var stock = parseInt($total.text())+parseInt($amount.val());
StockRecorder.Update($id.val(), stock);
RenderAmount();
});
$(\'.btn-sub\').click(function () {
var stock = parseInt($total.text()) - parseInt($amount.val());
StockRecorder Upadate($id.val(), stock);
RenderAmount();
});
$(\'.btn-set\').click(function () {
srockRecorder.Update($id.val(),parseInt($amount.val()));
RenderAmount();
});
RenderAmount();
});
});

