Having Trouble Getting Formula in Code to Compute Correctly
Hi everyone, I'm taking an entry level software programming class and am having to write a fairly simple code but can't seem to get it to compute right. This is what my code looks like as of now.
Welcome to Cheap Beds, Inc.! Please answer the following questions so we know how much to charge our customers.
Origprice = prompt('Enter the Original Price of the bed');
DelivFee = prompt ('How much are we charging for delivery?');
credit = prompt ('How much are we crediting for their old unit?');
Newcost = (parseInt(Origprice) + parseInt(DelivFee));
Finalcost = (parseInt(Newcost) - parseInt(DelivFee));
alert("The bed that was chosen will cost" + Finalcost + " Including delivery fee and trade-in credit for their old bed");
The cost of the bed that I'm entering is 100, shipping is 20 and credit is 5 but at the end it's saying that the price is 100? Does anyone know how I can fix this?
As simple as the fact that you are adding Origprice and DeliveFee and then deducting the DeliveFee again instead of the credit, should be:
Finalcost = (parseInt(Newcost) - parseInt(credit));
Agh! I had a feeling it was just something I had out of order in the code.
Originally Posted by simplypixie
Thank you very much for your help!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)