how do you make a statement that allows you to calculate percentage?
Percentage
Page 1 of 15 Replies - 10683 Views - Last Post: 20 August 2012 - 03:42 PM
Replies To: Percentage
#2
Re: Percentage
Posted 12 February 2009 - 03:20 AM
#3
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
The general rule is:
percent =(selectionOfGroup/totalInGroup)*100
#4
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
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;
System.out.println("Your Percentage is" + percent);
}
}
The output is always zero.
#5
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
Re: Percentage
Posted 20 August 2012 - 03:42 PM
Let's avoid needless necroposting in the future. Topic closed.
Page 1 of 1
|
|

New Topic/Question
This topic is locked




MultiQuote







|