Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2013, 04:27 AM   PM User | #1
JavaLearner22
New to the CF scene

 
Join Date: Mar 2013
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
JavaLearner22 is an unknown quantity at this point
Javascript - discount calculations

You have a product that is on sale. Each day of the sale, the price drops 10% from its previous price. The sale lasts for 4 days. I have to write a program that processes this problem using a loop. Each pass through the loop should generate the sale price for a a day of the sale and display that price along with the day number.

Which loop would I use ? I cannot seem to figure this out.
JavaLearner22 is offline   Reply With Quote
Old 03-20-2013, 04:45 AM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,797
Thanks: 30
Thanked 462 Times in 456 Posts
jmrker will become famous soon enough
Lightbulb

If you know the limits of the loop, why not just use them.
Code:
for (var day = 1; day <= 4; day++) {
// discount calculations and display

}
jmrker is offline   Reply With Quote
Users who have thanked jmrker for this post:
JavaLearner22 (03-20-2013)
Old 03-20-2013, 08:32 AM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,102
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
@JavaLearner22

You should be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
coding, javascript, program

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:06 PM.


Advertisement
Log in to turn off these ads.