-4
    cyan = (white - (red / 255)) / white*100.0;
    magenta = (white - (green / 255)) / white*100.0;
    yellow = (white - (blue / 255)) / white*100.0;
    black = (1 - white)*100.0;

I get my program executed with the decimal number, how can I change to the integers and get the whole numbers??

1 Answers1

0

If you need to round up a decimal, you should use (int) Math.ceil(x); if you need to round to the biggest integer:

System.out.println((int) Math.ceil(2.1)); // prints 3

Otherwise you should use Math.round(x) which returns integer value closest to the nearest integer:

System.out.println(Math.round(2.1)); // prints 2
System.out.println(Math.round(2.7)); // prints 3
Nowhere Man
  • 19,170
  • 9
  • 17
  • 42