#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    40
    Rep Power
    1

    Giving Percentages to numbers


    Hello, I'm new to these forums and decided to join when I heard from a few friends that this was the best forum on the net for programming. I hope to learn a lot from you guys. Now onto the problem.

    I was wondering how I would take a previous given number and give it a percentage. For example If I give three numbers and a final number. I want the final number to be 30 percent of the first number, 20 percent of the second number, and 50 percent of the third. How would I do something like that? I am confused at this point because I have never done anything like this before. Any help would be appreciated thanks.
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Multiply the numbers with respectively 0.3, 0.2 and 0.5 and then add the result together.

    If you need more help, you will have to show what you have done/tried. For example, where does the numbers come from?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    40
    Rep Power
    1
    Originally Posted by MrFujin
    Multiply the numbers with respectively 0.3, 0.2 and 0.5 and then add the result together.

    If you need more help, you will have to show what you have done/tried. For example, where does the numbers come from?
    This is what I have so far.

    var Hmwkgrade = window.prompt("Enter Your Homework Grade","");
    var Responsibilitygrade = window.prompt("Enter Your Responsibility Grade","");
    var Finalgrade = window.prompt("Enter Your Final Grade","")
    var HG = (Hmwkgrade*75)
    var RG = (Responsibilitygrade*10)
    var FG = (Finalgrade*15)
    var Totalgrade = (HG + RG + FG)
    document.write(Totalgrade );

    The numbers seem to be much higher than they should be.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    I think this is more a problem of elementary math (and not reading carefully enough) than it is a programming issue.

    75 per cent(!) of Hmwkgrade is 75 hundreds of it. It's not 75 times Hmwkgrade.

    I mean, I do wish that an interest rate of 3% would triple the capital each each. But unfortunately, that's not what "per cent" means.

    So what you want is

    Code:
    Hmwkgrade * 0.75
    MrFujin actually said this in his reply.
    The 6 worst sins of security How to (properly) access a MySQL database with PHP

    Why cant I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    40
    Rep Power
    1
    Originally Posted by Jacques1
    I think this is more a problem of elementary math (and not reading carefully enough) than it is a programming issue.

    75 per cent(!) of Hmwkgrade is 75 hundreds of it. It's not 75 times Hmwkgrade.

    I mean, I do wish that an interest rate of 3% would triple the capital each each. But unfortunately, that's not what "per cent" means.

    So what you want is

    Code:
    Hmwkgrade * 0.75
    MrFujin actually said this in his reply.
    Thanks, I made such a stupid mistake, I copied a a particular part of a program I made and didn't adjust it. Thank you for your help.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    40
    Rep Power
    1
    Originally Posted by MrFujin
    Multiply the numbers with respectively 0.3, 0.2 and 0.5 and then add the result together.

    If you need more help, you will have to show what you have done/tried. For example, where does the numbers come from?
    How would I be able to give the total grade a letter value, for example A+ >=95 would I need to use an array?

IMN logo majestic logo threadwatch logo seochat tools logo