Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help....Java

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Location
    Butuan city
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help....Java

    i want to read the numbers and the output would be odd and even into separate notepad.....
    here's my code....


    import java.io.*;
    import java.util.*;
    public class Vowel1 {
    static int st,odd,even;
    public static void main(String args[])throws IOException {

    Scanner s=new Scanner (new BufferedReader(new FileReader("D:\\numbers.txt")));

    BufferedReader inputStream=null;
    PrintWriter outputStream=null;
    PrintWriter outputStreams=null;

    inputStream = new BufferedReader(new FileReader("D:\\numbers.txt"));
    outputStream=new PrintWriter(new FileWriter("D:\\odd.txt"));
    outputStreams=new PrintWriter(new FileWriter("D:\\even.txt"));

    while(s.hasNextInt()){
    st=s.nextInt();

    if(st%2==0){
    odd=odd+st;
    }
    else if ( st% 2 != ' '){
    even=even+st;
    }

    outputStream.println(odd);
    outputStreams.println(even);
    }
    inputStream.close();
    outputStream.close();
    outputStreams.close();
    }
    }

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help....Java

    Please read the Announcement topic at the top of the sub-forum to learn how to post code in code or highlight tags and other useful info for newcomers.

    What questions do you have or problems are you experiencing that you'd like help with.