Q&A for How to Calculate Percentage in Java

Return to Full Article

Search
Add New Question
  • Question
    How do I write 5.365 as a percentage?
    Community Answer
    536.5% (original number times 100).
  • Question
    Should I use float instead to find percentages? (It's for an exam.)
    Community Answer
    It really depends on the application. A float variable will give you more precise values with decimals, and an int variable will give you rounded whole numbers.
  • Question
    How do I get decimal points instead of zero?
    Community Answer
    You use a float or double instead of int. A double is more accurate, but you won't necessarily use that more than a float.
  • Question
    How do I make a java program to find sums and averages?
    Community Answer
    The above shown code can perform the averages, but to perform sums, you would simply follow the above code, use it to take more inputs from user and store them in variables. Then once they are stored, you would simply do variableResult = VaraibleOne + VariableTwo + VariableThree + ... Once you have the variableResult all summed up, you can then using the above shown average code. Better practice would be first create a SUMS only program and then combine both Sums and Averages into a single program.
  • Question
    How to calculate percent to decimal in Java?
    Daniel
    Community Answer
    You would use the division operator to divide the percentage by one hundred. Example: System.out.println(50/100); 50% equals 50/100, which is 0.5.
Ask a Question

      Return to Full Article