JavaScript fun: flavoring Evaporator

Source: Internet
Author: User
The question is to test an evaporator containing an aromatic agent to see its service life. We know the size of the evaporator content (ml for calculation). The fragrance in it will evaporate a certain percentage (evap_per_day) every day ). The question is to test an evaporator containing an aromatic agent to see its service life.

We know the size of the evaporator content (ml for calculation). The fragrance in it will evaporate a certain percentage (evap_per_day) every day ).

This evaporator requires at least threshold (percentage) fragrance, otherwise it will no longer be used.

All numbers are positive.

After how many days, the evaporator will expire.

The function prototype is as follows:

Function evaporator (content, evap_per_day, threshold)

The parameters are capacity, volatile percentage, and minimum percentage.

In fact, it doesn't matter if you don't need the capacity. You can also use the percentage to solve this problem, but I think it is better to understand the capacity.

The following is the capacity solution, which determines the remaining capacity after daily volatilization until the current capacity is less than the minimum limit capacity, and returns the number of days.

Function evaporator (content, evap_per_day, threshold) {var day = 0; threshold = content * threshold/100; while (content> = threshold) {content * = (1-evap_per_day/100); day ++;} return day ;}

The above is the JavaScript interesting question: the content of the fragrance evaporator. For more information, please follow the PHP Chinese Network (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.