Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package exam;
  2. import java.io.*;
  3. public class Main(){
  4. public static void main (String [] args){
  5.    
  6.     String filename="d://input.txt";// 18 13 15 20 10 13 16 13 30 20 18
  7.     String line="";
  8.     int i=0;
  9. try{
  10.     FileReader fr=newFileReader(filename);
  11.     BufferedReader br=new BufferedReader(fr);
  12.     while((line=br.readLine())!=null){
  13.  
  14.     System.out.println("the odd numbers are: ");
  15.        String []parts=line.length;
  16.         for(int x=0; x<parts.length; x++){
  17.           i=Integer.parseInt(parts[x]);
  18.            if((i%2)==1){
  19.             System.out.print(i);
  20.                 }
  21.                         }
  22.     System.out.println("the even numbers are: ");
  23.            for(int j=0; j<parts.length; j++){
  24.           i=Integer.parseInt(parts[x]);
  25.               if((i%2)==0){
  26.             System.out.println(i);
  27. }
  28. }
  29. }
  30. }
  31. catch(IOException ex){
  32. System.out.print("error");
  33. }
  34.    
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement