Reputation: 21
Hey how i can check if my input is past 100 and return by how much it is? For example My current is 50 and i wan't to add 60 more, i want to return 10. I tried something like this:
public static void addPoints(int current, int amount) {
int left = 0, total = 0;
if(current + amount > 100) {
left = amount - current ;
total = amount + current;
}
System.out.println("You got " + total +" and " + left + " over 100.");
}
Upvotes: 1
Views: 52
Reputation: 127
Try this:
public static void addPoints(int current, int amount) {
int total = amount + current;
System.out.println("You got " + total +" and " + (total-100) + " over 100.");
}
Upvotes: 3