The question is this. There is a task and 2 variables x and y. These variables are entered in the user and they are percentages by the condition of the problem. My mentor gave me a "hint": Numbers must be converted to percents x / = 100; y / = 100; I can't understand what these expressions mean.

    1 answer 1

    This means that the number should be divided by 100 , just a brief entry, something like x += 100 , which will look like x = x + 100 in decrypted form. In your case, x = x / 100 .

    Accordingly, if your user enters anywhere on your data entry request, how many percent will you have the content of something in something (well, or what is the applied subject of your task), then it will be convenient for him to enter numbers.

    But it will be more convenient and correct for you in the calculations to use not these values, but their values ​​divided by one hundred. Thus, it is much easier to calculate the percentages from something later - for example, 25% of us, after calculations, will be the number 0,25 . Accordingly, in order to calculate how much will be 25% of any number, you just need to multiply this number by 0,25 .

    In general, school mathematics, not sure what to explain here.

    • I made a formula that displays a discount in discount percent function getPercentages (sum, discount) {return sum - ((sum / 100) * discount); Where a discount is the value of x or y, depending on the condition. Is it possible to use this formula, and not the hint that the mentor gave me? - Alexey Dodoka
    • one
      Well, it looks all right, although, of course, this is not quite on the subject of your question. In general, you can either first convert your x or y according to the formula that your mentor has given you, or you can do this conversion into functions, as you actually did. To do it anyway - do not care, unless these values ​​are used elsewhere, resulting in the need for some uniformity. - Stanislav Belichenko
    • one
      thank you so much! - Alexey Dodoka