Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

2/4 ??

int i =2;
int j =4;

I want to print the result of (2/4%) as 50% in java, how to do it?

what I did:

int n=i/j ; I got n is 0;
0
keepworking
Asked:
keepworking
1 Solution
 
objectsCommented:
double n = (double) i / (double) j;
System.out.println(n+":"+NumberFormat.getPercentInstance().format(n));
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now