int buyCost=4321;
int sellCost=4252;
int profit=100;
int x=100*profit*sellCost/buyCost;
profit=x/100;
System.out.println (profit);
profit=98 and this is the limit.
The next one (100 into 1000)
int buyCost=4321;
int sellCost=4252;
int profit=1000;
int x=1000*profit*sellCost/buyCost;
profit=x/1000;
System.out.println (profit);
X=-9
And the further up i go the more it misses.
I am trying to get somewhere at least 4+ digits and because I don't know how to make decimal points I was going this way.
I believe your problem lies in the order of operation. Try putting parentheses around the two integers that are being divided.