Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

### #1 Cecilia421

Cecilia421

• Members
• 114 posts
• OFFLINE
•
• Gender:Female
• Location:Walton, KY
• Local time:07:32 AM

Posted 26 April 2015 - 02:44 PM

Hi, everybody,

I have this assignment for a college course. My professor is not replying to my emails. I've had no experience with programming at all, and up until now, the course was entirely HTML/CSS. I'm supposed to write a Javascript program that will use prompt methods to take user information, process a microchip order and calculate the total cost with discount. Here is the code I've written. It's not working and I don't know why. Any suggestions?

function chipOrder(){
var chipAmount = prompt("Please enter the number of chips you wish to order.");
var origPrice = (chipAmount * 110);
var discountAmount;
if (chipAmount <= 19) {(discountAmount="0%");}
else if (20 <= chipAmount <= 49) {(discountAmount="2%");}
else if (50 <= chipAmount <= 79) {(discountAmount="4%");}
else if (80 <= chipAmount <= 99) {(discountAmount="6%");}
else (chipAmount >= 100) {(discountAmount="8%");}
var discountPrice;
if (chipAmount <= 19) {(discountPrice=origPrice*0);}
else if (20 <= chipAmount <= 49) {discountPrice=(origPrice * 0.02);}
else if (50 <= chipAmount <= 79) {discountPrice=(origPrice * 0.04);}
else if (80 <= chipAmount <= 99) {discountPrice=(origPrice * 0.06);}
else (chipAmount>=100) {discountPrice=(origPrice * 0.08);}
var totalPrice=(origPrice-discountPrice);
document.write("<h2>Customer Info</h2>");
document.write("Phone: " + userPhone + "<br>");
document.write("Email: " + userEmail + "<br>");
document.write("<h2>Order Info</h2>");
document.write("Number of chips: " + chipAmount + "<br>");
document.write("Cost per chip: \$110 <br>");
document.write("Discount/Amount: " + discountAmount + "/\$" + discountPrice + "<br>");
document.write("\$" + totalPrice + "<br>");
}
else {
document.write("Thank you for visiting. Please come again!")
}
}

"Life can only be understood backwards, but it must be lived forwards."
- Soren Kierkegaard

### #2 Cecilia421

Cecilia421
• Topic Starter

• Members
• 114 posts
• OFFLINE
•
• Gender:Female
• Location:Walton, KY
• Local time:07:32 AM

Posted 26 April 2015 - 02:52 PM

Nevermind. I finally found a javascript checker that showed me what I was missing.

Ahhhhhhh!!!

Thanks. I feel better now.

Ciao!

"Life can only be understood backwards, but it must be lived forwards."
- Soren Kierkegaard

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users