You know how groceries are cheaper when you buy them in bulk? What we're doing today is similar to that, but for buying ads in a newspaper: the more words in your ad, the more it's like buying groceries in bulk.
What we want is a program that will answer the question, "How much money do I owe the newspaper?"
For example, in JavaScript:
// Input Variables
var word_count = 80;
var tax_rate = 1.06;
var bulk_cutoff = 100;
var regular_price = 0.10;
var bulk_price = 0.08;
// Let's calculate the answer
var subtotal = 0;
if (word_count < bulk_cutoff){
subtotal = word_count * regular_price;
}
if (word_count >= bulk_cutoff){
subtotal = word_count * bulk_price;
}
var total = subtotal * tax_rate;
// Let's format the message
var message = "The total to place an ad of "+word_count+
" words with a tax rate of "+tax_rate+
" is "+total+
" dollars.";
// And let's output the message and be done
console.log(message);
= or == or === symbol to test equality between numbers? How would you write an if statement that means "if A is equal to B"? Demonstrate your answer with screenshots.word_count variable to 120 and the tax_rate variable to 1.07. Demonstrate your answer with screenshots.For each of the following, demonstrate your answer with screenshots of the program you wrote above being used to answer the word problem:
101 words, a bulk cutoff of 90 words, a regular price of 0.15 per word, a bulk price of 0.10 per word, and a tax rate of 1.08?89 words or 91 words?111 words cost? 112 words? 113 words? (Hint: to apply a seven percent discount, multiply by 0.93)