Percentage

Page 1 of 1

5 Replies - 10683 Views - Last Post: 20 August 2012 - 03:42 PM Rate Topic: -----

#1 HelloWorldLMAO  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • 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  Icon User is offline

  • New D.I.C Head

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

Re: Percentage

Posted 12 February 2009 - 03:20 AM

View PostHelloWorldLMAO, 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;

]


View PostHelloWorldLMAO, on 12 Feb, 2009 - 02:17 AM, said:

View PostHelloWorldLMAO, 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
Was This Post Helpful? 0
  • +
  • -

#3 OrganizedChaos  Icon User is offline

  • D.I.C Head

Reputation: 37
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 compstu  Icon User is offline

  • New D.I.C Head

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

Re: Percentage

Posted 19 August 2012 - 04:35 AM

View PostOrganizedChaos, 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;
        System.out.println("Your Percentage is" + percent);
        
    
    }
}


The output is always zero.
Was This Post Helpful? 0
  • +
  • -

#5 GregBrannon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1980
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9036
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1