JavaScript Sales App Activity
JavaScript Sales App Activity
Simple sales app:
<!DOCTYPE html>
<html>
<head>
<title>Activity</title>
</head>
<body>
<script type="text/javascript">
var regular_coffee = prompt("QTY of regular coffee");
var decaffeinated_coffee = prompt("QTY of decaffeinated coffee");
var mocha_coffee = prompt("QTY of mocha coffee");
var price_regular_coffee = regular_coffee*9;
var price_decaffeinated_coffee = decaffeinated_coffee*8;
var price_mocha_coffee = mocha_coffee*11;
var sum = price_regular_coffee+price_decaffeinated_coffee+price_mocha_coffee;
var discount = 15;
var total_cost = sum-discount;
document.write('Your purchased '+regular_coffee+' bags of regular, totaling '+price_regular_coffee+ " Rs<br><br>")
document.write('Your purchased '+decaffeinated_coffee+' bags of decaf, totaling '+price_decaffeinated_coffee+" Rs<br><br>")
document.write('Your purchased '+mocha_coffee+' bags of mocha, totaling '+price_mocha_coffee+" Rs<br><br>")
document.write('Your total purchase cost is '+sum+" Rs<br>")
if(sum>100){
document.write('Your total discount is '+discount+" Rs<br>")
}
else{
}
if(sum>100){
document.write('Your total cost with discount is '+total_cost+" Rs<br>")
}
else{
}
</script>
</body>
</html>
No comments:
Post a Comment