# Percentage

Page 1 of 1

## 5 Replies - 10683 Views - Last Post: 20 August 2012 - 03:42 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=86315&amp;s=a68857a1a3f8d3e3303eecd26d82a064&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 HelloWorldLMAO

Reputation: 1
• Posts: 39
• Joined: 12-February 09

# Percentage

Posted 12 February 2009 - 03:03 AM

how do you make a statement that allows you to calculate percentage?
Is This A Good Question/Topic? 1

## Replies To: Percentage

### #2 HelloWorldLMAO

Reputation: 1
• Posts: 39
• Joined: 12-February 09

## Re: Percentage

Posted 12 February 2009 - 03:20 AM

HelloWorldLMAO, on 12 Feb, 2009 - 02:03 AM, said:

how do you make a statement that allows you to calculate percentage?
i put this and it didnt work

[
if ( totalHours < 40)
totalRate = totalRate + 25/totalRate;
else
totalRate = totalRate;

]

HelloWorldLMAO, on 12 Feb, 2009 - 02:17 AM, said:

HelloWorldLMAO, on 12 Feb, 2009 - 02:03 AM, said:

how do you make a statement that allows you to calculate percentage?
i put this and it didnt work

[
if ( totalHours < 40)
totalRate = totalRate + 25/totalRate;
else
totalRate = totalRate;

]

i mean .25

### #3 OrganizedChaos

Reputation: 37
• Posts: 150
• Joined: 29-November 08

## Re: Percentage

Posted 12 February 2009 - 07:22 AM

What are you trying to calculate the percentage of?
The general rule is:
percent =(selectionOfGroup/totalInGroup)*100

### #4 compstu

Reputation: 0
• Posts: 2
• Joined: 14-August 12

## Re: Percentage

Posted 19 August 2012 - 04:35 AM

OrganizedChaos, on 12 February 2009 - 07:22 AM, said:

What are you trying to calculate the percentage of?
The general rule is:
percent =(selectionOfGroup/totalInGroup)*100

I tried this but it did not work
```
if (score >= 0 && score <= 3){
System.out.println("Dude which planet do you live on? Your score is " + score + " shame on you");
}
if (score >= 4 && score <= 6){
System.out.println("Dude you need to catch up with the world! Your score is " + score + " shame on you");
}
if (score >= 7 && score <=9){
System.out.println("You did OK, nothing to write home about! Your score is " + score + " shame on you");
}
if(score >=8 && score==10){
System.out.println("super dude, what does your dad feed you?! Your score is " + score + " Awesome!");
}
int a=10;
float percent=(score/a)*100;

}
}

```

The output is always zero.

### #5 GregBrannon

• D.I.C Lover

Reputation: 1980
• Posts: 4,824
• Joined: 10-September 10

## Re: Percentage

Posted 19 August 2012 - 04:52 AM

If score and a are both ints, then dividing an int by an int will not result in a fractional or decimal number. Change or cast either a or score to a floating point variable.

### #6 macosxnerd101

• Self-Trained Economist

Reputation: 9036
• Posts: 33,516
• Joined: 27-December 08

## Re: Percentage

Posted 20 August 2012 - 03:42 PM

Let's avoid needless necroposting in the future. Topic closed.