Java level calculator if statement returning the wrong value (Newbie)

后端 未结 6 1499
野的像风
野的像风 2021-01-21 09:48

i\'m learning some Java and decided to do something simple but it keeps returning the wrong value... i don\'t know why i\'m sure there something that my untrained eye isn\'t pic

6条回答
  •  Happy的楠姐
    2021-01-21 10:14

    I think you just need to change your || (or) to && (and). Otherwise, if your xp is 12 which is greater than level1xp (0), your program will set your level to level 2 immediately because of this if statement:

    else if (userxp >= level1xp || userxp < level3xp)
    

    An xp level of 12 will pass these requirements since 12 is greater than 0. Changing || or && will solve this problem I think. Let me know if you have any other problems after that.

提交回复
热议问题