Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

the isPrime method in java.

Name: Anonymous 2006-10-17 1:20

Write a method name isPrime, Which takes an integer as an argument and returns true if the argument is a prime number,or false otherwise.

what i dont understand about what it is asking me to do though is whether i should actually type in a random number while the program is running or should i have it read from a simple txt. file. and if i do have to type in a random number lets say 5 it would return true, but am i supposed to program that 5 into the code for it to be able to recognize it as a prime number or is that already determinded with the isPrime method?

I started learning Java only recently... so far coding has interested me a lot but the way that java fuckin does things is just so... fuckin annoying... i now understand why you guys flame it so much sometimes.

any advice on what i should do about this java thing would be really appreciated.

Name: Anonymous 2006-10-17 1:50

so far i have something like this... am i doin it right?

import java.io.*;
      public class Prime{
           
         public static void main(String[] args) throws Exception, IOException
             {
            InputStreamReader a= new InputStreamReader(System.in);
            BufferedReader stndin= new BufferedReader(a);
            boolean isprime=true;
             String snum;
             int inum;
             System.out.println("Enter a number:  ");
             snum=stndin.readLine();
             inum=Integer.parseInt(snum);

             int j=inum%2;

            
              if (j==1){
              System.out.println("prime ");
              }else{
              System.out.println("composite");}
       
     
           
         }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List