1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lions [1.4K]
3 years ago
7

Suppose we can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. We can redeem s

ix coupons for one chocolate bar from the machine. This means that once you have started buying chocolate bars from the machine, you always have some coupons. We would like to know how many chocolate bars can be eaten if we start with N dollars and always redeem coupons if we have enough for an additional chocolate bar.For example, with 6 dollars we could consume 7 chocolate bars after purchasing 6 bars giving us 6 coupons and then redeeming the 6 coupons for one bar. This would leave us with one extra coupon. For 11 dollars, we could consume 13 chocolate bars and still have one coupon left. For 2 dollars, we could have consumed 14 chocolate bars and have two coupons left.Write a program that inputs a value for N and outputs how many chocolate bars we can eat and how many coupons we would have left over. Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar.
Computers and Technology
1 answer:
Tanya [424]3 years ago
7 0

Answer and Explanation:

Using JavaScript:

/* program should take N input which represents the dollar amount and output how many chocolate bars and how many coupons we have*/

function chocolatebar(dollars){

var dollaramt= dollars;

var i;

for(i=0; i <= dollaramt; i++){

i=i+6

?

Alert ("you have 1 extra chocolate bar");

:

Alert ("keep buying chocolate bars to get more coupons for a bonus chocolate bar")

}

}

*

You might be interested in
To prevent rust from forming, a light coating of_____should be applied to all machined surfaces
Fantom [35]
What is that I never heard of that before
4 0
3 years ago
Danielle is analyzing logs and baselines of the systems and services that she is responsible for in her organization. She wants
GalinKa [24]

Answer:

b. Machine learning

Explanation:

The technique that is being described in this situation is known as Machine Learning. This is a fairly new technology that has become popular over the last decade. Machine learning uses artificial intelligence to analyze data and learn from it. Every time the system analyzes the data it learns something new, saves it, and implements it to its processes. Therefore, the more times it repeats the more it learns. These systems are continuously getting better and learning more, which makes them incredibly efficient.

5 0
2 years ago
What did Muhammad do when he encountered opposition from Mecca’s city leaders? He brought more followers to Mecca. He relocated
Rudiy27

Answer:

He relocated from Mecca to the city of Medina.

Explanation:

5 0
3 years ago
Read 2 more answers
I have science project competition. From where can i buy the parts i dont know any nearby place
dangina [55]
Uuuhh how bouut Walmart or anywere u want really

6 0
3 years ago
You need to increase the security of your linux system by finding and closing open ports. which of the following commands should
spayn [35]
Netstat -pan | more


-----------------------------------------------------
5 0
3 years ago
Other questions:
  • A virus has attacked your hard drive and now when you start up Windows, instead of seeing a Windows desktop, the system freezes
    9·2 answers
  • What port in your computer will you use to plug in your camera?
    14·2 answers
  • You can use the Ignore All button to ignore the current and all future occurrences of a flagged word. True or False
    5·1 answer
  • Working with text in presentation programs is similar to using text in other applications
    9·2 answers
  • Which result is most likely if a network packet has no header?
    9·2 answers
  • I nees the meaning of these words even just one of them would help out ( pixel megapixel colour depth bit and byte)
    15·2 answers
  • What actions can you take to ensure the physical security of network devices?
    14·2 answers
  • Heres a meme<br><br>free pints as well, because why not.​
    10·2 answers
  • Join my FNAF fan club discord
    6·2 answers
  • Explain to Alana why she might not want to blast her boss on social media just yet.<br>​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!