Java rounds number i don't want?

class CombatCalc {
    public static void main(String[] args) {
         int att = 99;
         int str = 99;
         int def = 97;
         int hp = 99;
         int pray = 74;
         int mage = 97;
         int range = 89;
         int a = def*100;
         int b = hp*100;
          int c;
              if (pray % 2 ==0){  //number is even
                    c = pray * 50;
               }else{
                    c = ((pray - 1) * 50);      //number is odd
         double basecomb = ((a + b + c)/400);
         int d = att*130;
         int e = str*130;
               int f;
               int g;
              if (range % 2 !=0){ //number is odd
                    f = ((range -1)+(range*2))*65;
               }else{
                    f = range*195;
               if (mage % 2 !=0){ //number is odd
                    g = ((mage -1)+(mage*2))*65;
               }else{
                    g = mage*195;
          double meleecmb = 0;
          meleecmb = ((d+e)/400);
          double magecmb = 0;
          magecmb =  g/400;
          double rangecmb = 0;
          rangecmb = f/400;
          double cmb = 0;
          if (meleecmb > rangecmb || meleecmb > magecmb){
                cmb = basecomb + meleecmb;
          }else if (rangecmb > magecmb || rangecmb > meleecmb){
                cmb = basecomb + rangecmb;
          }else if (magecmb > rangecmb || magecmb > meleecmb){
                cmb = basecomb + magecmb;
        System.out.println("Base= " + basecomb); // Display the string.
        System.out.println("Melee= " + meleecmb); // Display the string.
        System.out.println("Range= " + rangecmb); // Display the string.
        System.out.println("Mage= " + magecmb); // Display the string.
        System.out.println(cmb); // Display the string.
}It rounds all numbers i get, If i take a calculator and calculate them manually, i get other results, for example basecomb = ((a+b+c)/400), in this case i get (9900+9700+3700)/400=58,25, But it prints out 58. For everything, it rounds down, I don't want it to round, What should i do? Is there a mistake somewhere?

The problem here is that you're using integer division.
Even though you've created basecomb to be a double, the inputs a, b, c, and 400 are all integers, so Java assumes you are doing integer division, and truncates the results.
The easiest way to fix this is to change 400 to 400.0 or 400f, both of which tell java that it is a floating point number, so it will perform floating point division and won't truncate the result.
- Adam

Similar Messages

  • How do I reinstall Lr 5?  I have my serial number and don't want to pay for Lr 5 CC.

    How do I reinstall Lr 5?  I have my serial number and don't want to pay for Lr 5 CC.

    If you don't have an Installer disk then you can't install without a purchase. Do you have the grey SystemRestore disks that came with your Mac? It's on that. No, iPhoto is not part of Lion.
    Regards
    TD

  • Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    Hi, how can I limit the number of emails I can see on my iPhone 5. Every time in delete one and older email gets added from my live.co.uk account (where I want to keep my 2500 emails) I just don't want many on my phone. Thanks

    You can't. Why on earth would you attempt to manage 2500 emails with setting up a folder structure or some means of doing so? Simply keeping them in an single inbox is not realistic, no matter what email client you use.

  • How can I find my serial number for Adobe Acrobat 11. I got a new iMac and I don't want to use the new version at £18.00 per month. I don't need it. Thank you

    I used to use CS5 and I want to use the Acrobat version on my new iMac.
    How can I find my serial number for Adobe Acrobat 11.  I don't want to use the new version at £18.00 per month. I don't need it. Thank you

    Hi Anthony Aduhene
    Please refer : Find your serial number quickly

  • I need to register my PS and I have the numbers but it wont let me register online, only on the phone. So I called the number and it I have to take a surve for a freaking trip that I DON"T want. If I don't regiester my photo shop it will not stay up. How

    I called the number to register my photo shop but I have answer some questions for a freaking trip that I don't want supposed to be "FREE" and I asked to be redirected but the people wont do it. They hung up on me twice. Can someone PLEASE help me register my Photo shop? It will not stay open if it is not registered.

    This whole deal reeks. I do not know where you got your product from, but that's not how Adobe Photoshop works.
    Go here first: Contact Customer Care
    That is the official contact.
    Contact Customer Care by chat or Phone.
    If the website you went on is not www.adobe.com, close the browser.
    If the number is for a "survey" to "win a trip", hang up. It's a scam to get your credit card in order to "secure" the trip.

  • How can i delete a number of emails at once?  I have a backlog and don't want to go through them all.

    how can i delete a number of emails at once?  I have a backlog and don't want to go through them all.

    No.
    With an Exchange or IMAP account you can delete the messages with the email client used on your computer or via webmail access for the account - all server stored mailboxes are kept synchronized with the server with each email client used to access the account.
    Not possible with an antiquated POP account.

  • Looking for a FREE malay / english bi directional dictionary for my mac book, haven't registered my apple id cause don't want to put my credit card number, so must be from other place than iTunes

    looking for a FREE english to malay and malay to english (bidirectional) dictionary (kamus) to dowload to my mac book for use off line. i don't want to put my credit card number in my aplle id profile, so looks like any free app in i tunes is out for me. Any body know of a good dictionary, easy to down load, no fuss or gimmiks (no free trials etc) or even a free and good malay language course... I've tried serching by google and on cnet but can't seem to find anything straight foward that will download......as you probably have guessed by now, i'm definetly no computer geek, just an old fella trying to use some of this new fangled technology, so hope somebody can suggest something plain and simple....thanks to all

    http://translate.google.com
    or
    http://kamus.lamanmini.com/
    http://www.malayenglishdictionary.com/en/dictionary-malay-english
    http://www.stars21.com/dictionary/English-Malay_dictionary.html

  • How do i setup Mail account on my mac book like in mobile phone? I.e. Don't want to store the mails/attachments on pc, however need the latest emails for given number of days?

    How do i setup Mail account on my mac book like in mobile phone? I.e. Don't want to store the mails/attachments on pc, however need the latest emails for given number of days?
    This helps the storage and purpose of email as well. I could always log into online email account to find history of emails.
    Thanks
    Chai

    How do i setup Mail account on my mac book like in mobile phone? I.e. Don't want to store the mails/attachments on pc, however need the latest emails for given number of days?
    This helps the storage and purpose of email as well. I could always log into online email account to find history of emails.
    Thanks
    Chai

  • My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?

    My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?And all the sounds on my phone are on, even the keyboard clicks.

    Try restarting your iPhone by holding down the on/off and the home buttons at the same time until you see the Apple logo, double check the volume button just in case.  If you still can't hear the tones go into your settings>sounds and make sure the options are on. 

  • HT2534 in my iphone5 'none' option for credit card is not being appeared. May be because of software upgrade or wot it is really not good as i don't want to share my credit card number.

    the 'none' option under payment methods is not being appeared in my iphone 5 as i don't want to share my credit card info. and my id stuck over that point as i am not abble to skip this step and it is a must option to select a credit card type and give a real credit card details. This is really not good.

    You have to enter your credit card number and some amount would be debited from your account(60 rs in india)
    After registration, You can Go to
    1 Settings
    2.Itunes&App Store
    3.Click on your apple id .
    4.Select View Apple ID
    5.Slecet Payment Info
    And You can find NONE here.
    Please select NONE to delete your credit card numbe r from the list
    But While registering you cant find NONE, you have to enter the cc number.
    Thank You
    Tejas

  • A private web screen shows up when I close down apps on my ipad, but I don't want to see that web page EVER.  It is a private "incognito" Skype number that I don't want ANYONE to see.

    A private web screen shows up when I close down apps on my ipad, but I don't want to see that web page EVER.  It is a private "incognito" Skype number that I don't want ANYONE to see.

    Yeah, I'm 95% sure that I did that after I closed that Skype, so I was a bit shocked when I saw that screen pop up later :/

  • Using iMessage 8.0 with Mavericks to send sms message to my friend who has an iPhone.  Only allows me to log in under AIM, YAHOO, GOOGLE, or BONJOUR.  I don't want to do any of that.  Just my phone number.  Is this possible?

    Using iMessage 8.0 with Mavericks to send sms message to my friend who has an iPhone.  Only allows me to log in under AIM, YAHOO, GOOGLE, or BONJOUR.  I don't want to do any of that.  Just my phone number.  Is this possible?

    Hi,
    The first run of Messages will ask you to enter an Apple ID to "register' with iMessages.
    If you do not do this but open the App and look in Preferences > Accounts then you will see the iMessages account and the Bonjour Account which will not be activated.
    Neither of these two account can be deleted. (even if not being used)
    If you then press the + icon to add you will get the choices you posted.
    To iMessage you need to "register" and Apple ID with the iMessages service.
    As Diane then points out you can link this to your iPhone number.
    This "syncs" (Displays on all devices) the various iMessages sent to either iPhone or Apple ID
    You can then chose  on both iPhone or Mac version how or which ID/Number is going to be used to "Start the conversations from"
    I have my Mac version set to start from my Apple ID and the iPhone from it's number.
    At this moment the Mac version cannot send SMS text messages to an iPhone.
    This is apparently coming with iOS 8 and OS 10.10 (Yosemite)
    An AIM account can send SMS Messages but only to a limited number of USA based phone users on these carriers.
    (Basically you add a phone number with country code +1 as a Buddy to your List)
    Mocked up number  (It not really an auto responder although you do get sent back and Error message about it not being valid)
    8:37 pm      Sunday; July 13, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Don't want my skype in number

    Hello, I purchased a Skype Number today for three months and wnat to cancel it and get my refund.  How do I do that?  All I see is how to do that for a subscription. I purchased it today, but I didn't get the email because it went to an old email that I know longer have.  I called in to the number twice seeing how it worked, but I we don't want to maintain a number and I didn't see any other way to just try it out.  Thanks fo ryour help!

    Hi, Jungheinrich, and welcome to the Community,
    What you describe is how I have my Caller ID set up, and it works for me - I am in the USA.  Here is a link to the library of FAQ articles related to Caller ID, so you can peruse and make an informed decision - I do not know if Caller ID is upported in your location.
    https://support.skype.com/en/category/CALLER_IDENTIFICATION/
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Currently using Photoshop CS5, but with a replacement computer and upgrade to Yosemite, keep being told I need to install the legacy Java 6. Currently, Photoshop won't even open. I absolutely do not want to subscribe, don't want to mess with the cloud, ju

    Currently using Photoshop CS5, but with a replacement computer and upgrade to Yosemite, keep being told I need to install the legacy Java 6. Currently, Photoshop won't even open. I absolutely do not want to subscribe, don't want to mess with the cloud, just want to buy an upgrade to something that will run for a while longer. I don't care about Lightroom, Bridge, Illustrator, etc.; most of those I've deleted over the years. But I do use Photoshop - or would if it would still run. What options do I have?

    This is the java you need for photoshop cs5 to work on mac os x 10.10 Yosemite
    https://support.apple.com/kb/DL1572?locale=en_US
    It's also possible you may have to reinstall photoshop cs5 even after installing the above java, because sometimes the upgrade to mac os x 10.10 messes up the photoshop cs5 installation.
    You can download photoshop cs5 from here if you don't already have the install media.
    https://helpx.adobe.com/creative-suite/kb/cs5-product-downloads.html

  • HT204053 I don't want to receive any SMS from Apple. Could you remove my cell number from your list.

    I don't want to receive any SMS from Apple. Could you remove my cell number from your list?

    It's been suggested that somehow you may have emails being routed to your SMS, which is passing marketing emails from Apple to your text messaging. Go here:
    http://mynews.apple.com/ca/subscribe
    and unsubscribe and see if the SMS messages then stop. You can also check your Apple ID:
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    and make the change there if you are subscribed.
    Regards.

Maybe you are looking for