1
I have a statement that says I have to make a looping between 4 and 24, adding the index with a total value, with some points:
- If the index number is multiple of 5, it must add up to 3;
- If the index number is multiple of 3, it must subtract 4;
- If it is a multiple of 3 and 5, multiply the total value by 2;
The final result should be 190.
My code:
    public static void main(String[] args) {    
         int total = 0;
        for (int i = 4; i <= 24; i++) {
            //Somo o index com o valor total
            if ((i % 5 > 0) && (i % 3 > 0)) {
                total += i;
            }
            //Caso true a opção 3
            if ((i % 5 == 0) && (i % 3 == 0)) {
                total *= 2;
            }
            //Caso true a opção 2
            if (i % 3 == 0) {
                total -= 4;
            }
            //Caso true a opção 1
            if (i % 5 == 0) {
                total += 3;
            }
        }   
        System.out.println(total);
    }
} 
My result does not come out of 189, never to 190, I debugged but apparently my logic is right. What I can change to get to 190 correctly?