PRINTING THE NON-PRIMES
//PROGRAM FOR PRINTING THE NON-PRIMES INTO A FILE
//AUTHOR:SIVAPHANINDRA.VEMURI
import java.io.*; /*IMPORTING SECTION*/
class Task1e1 /* DECLARING A CLASS NAMED Task1e1*/
{
public static void main(String args[]) /*MAIN FUNCTION*/
{
FileOutputStream file_out=null; /* CREATING STREAMS FOR DIRECTING IT TO THE OUTPUT FILE*/
PrintStream pno=null;
try{
file_out=new FileOutputStream("non-primes.txt",false);
pno = new PrintStream(file_out,true);
}catch(FileNotFoundException e){ /* TO CATCH EXCEPTIONS */
System.out.println();
return;
}
catch(IOException e){
System.out.println("IOEXCEPTION");
return;
}
int num=2;
do
{
for(int i=2;i <num;i++)
{
if((num%i)==0) /*CHECKING FOR NON PRIMES*/
{
pno.println(num); /*FOR WRITING TO THE FILE */
pno.println();
break;
}
}
num++;
}while(num!=500); /*TO PRINT ALL THE NON PRIMES BETWEEN 1-500*/
}
}
//AUTHOR:SIVAPHANINDRA.VEMURI
import java.io.*; /*IMPORTING SECTION*/
class Task1e1 /* DECLARING A CLASS NAMED Task1e1*/
{
public static void main(String args[]) /*MAIN FUNCTION*/
{
FileOutputStream file_out=null; /* CREATING STREAMS FOR DIRECTING IT TO THE OUTPUT FILE*/
PrintStream pno=null;
try{
file_out=new FileOutputStream("non-primes.txt",false);
pno = new PrintStream(file_out,true);
}catch(FileNotFoundException e){ /* TO CATCH EXCEPTIONS */
System.out.println();
return;
}
catch(IOException e){
System.out.println("IOEXCEPTION");
return;
}
int num=2;
do
{
for(int i=2;i <num;i++)
{
if((num%i)==0) /*CHECKING FOR NON PRIMES*/
{
pno.println(num); /*FOR WRITING TO THE FILE */
pno.println();
break;
}
}
num++;
}while(num!=500); /*TO PRINT ALL THE NON PRIMES BETWEEN 1-500*/
}
}