formula for percent
formula for percent
I'm writing a program, and I need it to calculate the percent of two numbers entered. First, the teacher enters the number of registered students (student) and then the number of absent students (absent)
once these two numbers are inputed, what formula would I use to find the percent of absent students. For example, there are 345 students registered, and 4 are absent. what QB formula would I use in QB to tell me the percentage of students absent?
From what I can remember about percents wouldn't it be:
LET percent = absent / student
the answer doesn't come out correclty though. If somebody could shed some light on this topic it would be greatly appreciated
once these two numbers are inputed, what formula would I use to find the percent of absent students. For example, there are 345 students registered, and 4 are absent. what QB formula would I use in QB to tell me the percentage of students absent?
From what I can remember about percents wouldn't it be:
LET percent = absent / student
the answer doesn't come out correclty though. If somebody could shed some light on this topic it would be greatly appreciated
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
Try this. Tell me if it doesn't fit your needs, or doesn't work at all. I don't have any version of QB or FB where I'm at.
Code: Select all
' PQBC Percent Program
Input "Number to take percentage of? ", num1
Input "Percent to take? ", num2
Let percent = val(left$(str$(num1 / num2) * 100),10)
Print percent "%"
Last edited by Patz QuickBASIC Creations on Wed Aug 31, 2005 5:32 pm, edited 1 time in total.
As a rule, we don't help people with homework, like Z!re said. It sounds like homework to Z!re and to me too. If it's not homework, then what is it? Explain, and we'll help you.percent wrote:it's not homework, and I don't have any math teachers readily available
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
PQBC, that's what I had to begin with, but I keep getting an Overflow error. The calculation you gave me is in a subprogram and is being called to the main program, might that have something to do with the overflow?
Z!re, it's a practice assignment from my computer programming class. It isn't being submitted for a grade. The whole purpose of the assignment is to build a program using subprograms and CALL statements only. I have the formula down, but I keep getting an overflow error
Z!re, it's a practice assignment from my computer programming class. It isn't being submitted for a grade. The whole purpose of the assignment is to build a program using subprograms and CALL statements only. I have the formula down, but I keep getting an overflow error
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
Fixed, i think. Overflow won't occur with revised version.
Code: Select all
' PQBC Percent Program
Input "Number to take percentage of? ", num1
Input "Percent to take? ", num2
Let percent = val(left$(str$(num1 / num2) * 100),10)
Print percent "%"
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
-
- Coder
- Posts: 17
- Joined: Sat Aug 27, 2005 10:26 am
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
WEll me I'm 37 ...probably the biggest number you'll get here LOL
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com