Solved

percentages

Posted on 2004-10-10
5
357 Views
Last Modified: 2010-04-05
hey all, my question is

to keep it simple, lets say you have a bar thats 100 hundred long, and you have a line on it thats 36 long, what percentage would that line be long?
and vice versa, if you knew the percentage the line should be... how long would the line be?

Im usually very good in math, but for some reason Im having probs with this LOL
thanks in advance =)
0
Comment
Question by:LMuadDIb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
brunomsilva earned 125 total points
ID: 12272775
Hi LMuadDIb,

36/100 = 0.36 = 36%

to find the opposite, suppose the bar is 150 long and you want a line that has 10%, multiply 150 * 10% (0.1) = 15

Cheers!
0
 
LVL 4

Author Comment

by:LMuadDIb
ID: 12272830
with a funtion I made I get an
[Error] misc.pas(22): Incompatible types: 'Integer' and 'Extended'

in delphi code, if you wanted a button to be 25% of the width of the form its sitting on, how would you code it?
0
 
LVL 4

Author Comment

by:LMuadDIb
ID: 12272853
DOH!
I also figured out my error which was another DOH! ;)
thanx
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 12272867
Expanding on brunomsilva,

__________________________________________________
Part A)
To calculate it in delphi:

Percentage:=(36 div 100) * 100; //will give you the percentage of 36

PartB)
The opposite (using brunomsilva example):

Length:=(150 * (10 div 100)); //will give you the length of 15

__________________________________________________

Similarly if we use straight variables so that it can be changed dynamically:
Part A)

var Percentage,linelength,barlength:Integer;
begin
       Percentage:=(LineLength div BarLength) * 100;
end;

Part B)

var Percentamount,Linelength,barlength:Integer;
begin
      LineLength:=(BarLength * (PercentAmount div 100));
end;
__________________________________________________

Regards,

Hypoviax

 
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 12272870
I was a bit slow in typing my post!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question