Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MainStream

Pages: [1]
1
This looks very interesting. I'm going to go ahead and do some more research on it. :) Thanks for the share.

2
Java / Re: Simple equation totaly wrong
« on: December 24, 2014, 04:27:50 pm »
Code: [Select]
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)
Code: [Select]
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.

Pages: [1]