java - Can somebody please explain this code? -


i not understand code.
explain me step step (code code)?

note: purpose of method ask , recieve user input;
followed checking number see if it's prime number.

package prime; import java.util.scanner;  public class primetime {     public static void main(string [] args){         scanner input = new scanner (system.in);         system.out.print("enter number: ");         int = input.nextint();         boolean primenumber = true;         ( int b = 2; b < a; b++){             int z = a%b;             if (z == 0){                 primenumber = false;          }        }         if (a == 1){             system.out.println("(not a) prime number (1) (not mathematicians count 1 prime number)");         }         if (primenumber){             system.out.println("prime number (" + + ")" );         }         else{             system.out.println("not prime number (" + + ")");         }      } } 

i think understand imports, continue on 'main' method:

a scanner (new scanner(system.in)) taking inputs , transferring strings, ints, ... . scanner 1 of them. prints "enter number: ", , int a method of scanner called nextint(). client (the user) types number. creates boolean called primenumber , sets true. creates loop starts @ 2, , repeats untill it's a. does:

integer z leftovers of how b fits in (that operation called modulo or %). if z = 0, even, sum b/a hole number. primenumber false. @ end check primenumber is. prints text can see in code. i'm sure know if (and hope can read language of 'keine' or 'primzahl').


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

c++ - Producer-consumer based multi-threading for image processing -