lundi 2 janvier 2017

Simple java loop statement with if statements not running correctly? [on hold]

I am brushing up on my Java and cannot get this program to work correctly. It is a while counter loop counting up to 100. If the counter is divisible by 3 it will output "On", if the counter is divisible by 7 it will output "Base", if the counter is divisible by 7 and 3 it will output "OnBase", otherwise it will output the number. Right now the program will not even compile and I have no idea what the issue is. Here is my program, any help is appreciated.

public class Counter {

  public static void main(String[] args) {

    int i = 1;

    while(i <= 100)
    {

        if((i % 3) == 0){
            system.out.println("On");
            i++;
            continue;
        }

        if((i % 7) == 0){
            system.out.println("Base");
            i++;
            continue;
        }

        if((i % (3*7) == 0){
            system.out.println("OnBase");
            i++;
            continue;
        }

        system.out.println(i);
        i++;
    }
  }
}   

Aucun commentaire:

Enregistrer un commentaire