August 5th, 2013, 07:00 AM

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.
August 5th, 2013, 07:31 AM

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?
August 7th, 2013, 12:37 PM

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.
August 7th, 2013, 01:21 PM

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
MrFujin actually said this in his reply.
August 7th, 2013, 01:23 PM

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
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.
August 7th, 2013, 01:53 PM

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?