How to work out the percentage of how much someone has paid









up vote
1
down vote

favorite
1












I have been trying to google this for hours but am finding it hard to find the maths to achieve this.



If the total payment is 200 GBP and the user has paid 100 GBP - he has paid 50% of the total.



I am trying to translate this to an algorithm but cannot get the expected result.



I have tried:



($total / $paid) * 100;
(($total + $paid) / 100) * 2;
($total - $paid) / 100;


But neither of this is giving me 50% when I use 200 as the total payment and 100 as the amount paid. Any help would be appreciated. I'm not very good at maths.










share|improve this question



























    up vote
    1
    down vote

    favorite
    1












    I have been trying to google this for hours but am finding it hard to find the maths to achieve this.



    If the total payment is 200 GBP and the user has paid 100 GBP - he has paid 50% of the total.



    I am trying to translate this to an algorithm but cannot get the expected result.



    I have tried:



    ($total / $paid) * 100;
    (($total + $paid) / 100) * 2;
    ($total - $paid) / 100;


    But neither of this is giving me 50% when I use 200 as the total payment and 100 as the amount paid. Any help would be appreciated. I'm not very good at maths.










    share|improve this question

























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      I have been trying to google this for hours but am finding it hard to find the maths to achieve this.



      If the total payment is 200 GBP and the user has paid 100 GBP - he has paid 50% of the total.



      I am trying to translate this to an algorithm but cannot get the expected result.



      I have tried:



      ($total / $paid) * 100;
      (($total + $paid) / 100) * 2;
      ($total - $paid) / 100;


      But neither of this is giving me 50% when I use 200 as the total payment and 100 as the amount paid. Any help would be appreciated. I'm not very good at maths.










      share|improve this question















      I have been trying to google this for hours but am finding it hard to find the maths to achieve this.



      If the total payment is 200 GBP and the user has paid 100 GBP - he has paid 50% of the total.



      I am trying to translate this to an algorithm but cannot get the expected result.



      I have tried:



      ($total / $paid) * 100;
      (($total + $paid) / 100) * 2;
      ($total - $paid) / 100;


      But neither of this is giving me 50% when I use 200 as the total payment and 100 as the amount paid. Any help would be appreciated. I'm not very good at maths.







      php math percentage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 21:04









      Funk Forty Niner

      80.5k1247100




      80.5k1247100










      asked Nov 10 at 20:57









      Jaquarh

      2,962931




      2,962931






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Simply do:



          $percent = 100 * $paid/$total;


          To get the percent value up to two decimal places only, you can use the Round() function:



          $percent = ROUND(100 * $paid/$total, 2);





          share|improve this answer


















          • 1




            You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
            – Jaquarh
            Nov 10 at 20:59










          • @Jaquarh happy to help :)
            – Madhur Bhaiya
            Nov 10 at 21:14






          • 1




            Apologies - had to do something for a bit - accepted now! :)
            – Jaquarh
            Nov 11 at 11:22

















          up vote
          1
          down vote













          It is very simple just do this $percentPaid = $paid/$total * 100;






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243341%2fhow-to-work-out-the-percentage-of-how-much-someone-has-paid%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            Simply do:



            $percent = 100 * $paid/$total;


            To get the percent value up to two decimal places only, you can use the Round() function:



            $percent = ROUND(100 * $paid/$total, 2);





            share|improve this answer


















            • 1




              You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
              – Jaquarh
              Nov 10 at 20:59










            • @Jaquarh happy to help :)
              – Madhur Bhaiya
              Nov 10 at 21:14






            • 1




              Apologies - had to do something for a bit - accepted now! :)
              – Jaquarh
              Nov 11 at 11:22














            up vote
            4
            down vote



            accepted










            Simply do:



            $percent = 100 * $paid/$total;


            To get the percent value up to two decimal places only, you can use the Round() function:



            $percent = ROUND(100 * $paid/$total, 2);





            share|improve this answer


















            • 1




              You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
              – Jaquarh
              Nov 10 at 20:59










            • @Jaquarh happy to help :)
              – Madhur Bhaiya
              Nov 10 at 21:14






            • 1




              Apologies - had to do something for a bit - accepted now! :)
              – Jaquarh
              Nov 11 at 11:22












            up vote
            4
            down vote



            accepted







            up vote
            4
            down vote



            accepted






            Simply do:



            $percent = 100 * $paid/$total;


            To get the percent value up to two decimal places only, you can use the Round() function:



            $percent = ROUND(100 * $paid/$total, 2);





            share|improve this answer














            Simply do:



            $percent = 100 * $paid/$total;


            To get the percent value up to two decimal places only, you can use the Round() function:



            $percent = ROUND(100 * $paid/$total, 2);






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 10 at 21:03









            Funk Forty Niner

            80.5k1247100




            80.5k1247100










            answered Nov 10 at 20:58









            Madhur Bhaiya

            19.3k62236




            19.3k62236







            • 1




              You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
              – Jaquarh
              Nov 10 at 20:59










            • @Jaquarh happy to help :)
              – Madhur Bhaiya
              Nov 10 at 21:14






            • 1




              Apologies - had to do something for a bit - accepted now! :)
              – Jaquarh
              Nov 11 at 11:22












            • 1




              You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
              – Jaquarh
              Nov 10 at 20:59










            • @Jaquarh happy to help :)
              – Madhur Bhaiya
              Nov 10 at 21:14






            • 1




              Apologies - had to do something for a bit - accepted now! :)
              – Jaquarh
              Nov 11 at 11:22







            1




            1




            You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
            – Jaquarh
            Nov 10 at 20:59




            You are a star! I'm glad some of us are maths qualified on SO! Haha, thanks alot! Will accept as soon as I can.
            – Jaquarh
            Nov 10 at 20:59












            @Jaquarh happy to help :)
            – Madhur Bhaiya
            Nov 10 at 21:14




            @Jaquarh happy to help :)
            – Madhur Bhaiya
            Nov 10 at 21:14




            1




            1




            Apologies - had to do something for a bit - accepted now! :)
            – Jaquarh
            Nov 11 at 11:22




            Apologies - had to do something for a bit - accepted now! :)
            – Jaquarh
            Nov 11 at 11:22












            up vote
            1
            down vote













            It is very simple just do this $percentPaid = $paid/$total * 100;






            share|improve this answer
























              up vote
              1
              down vote













              It is very simple just do this $percentPaid = $paid/$total * 100;






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                It is very simple just do this $percentPaid = $paid/$total * 100;






                share|improve this answer












                It is very simple just do this $percentPaid = $paid/$total * 100;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 21:01









                Carsim Rheedwan Adedotun Holuw

                435




                435



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243341%2fhow-to-work-out-the-percentage-of-how-much-someone-has-paid%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo