Results 1 to 6 of 6

Thread: help

  1. #1
    jack18 is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default help

    i need a help

    write the program that prompts the student to enter his name and student number and write it into txt file then store it on specific variable according to it's data type and then print the data stored into variable as " the student name is ....and student number is" the program should handle any exception can happen

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: help

    1. Use a meaningful subject line, "help" isn't one.
    2. This is a forum, not a homework service. We are prepared to help you to learn -- not to do your work for you aka cheating.
    3. Use a capital letter at the start of each sentence and for the first person singular "I." If you're too lazy to depress the shift key, don't be surprised to find that other members here are too lazy to offer help.

    Did you take the time to go through the Guide For New Members and http://www.java-forums.org/content/113-forum-rules.html ? No? I thought not.

    db
    Last edited by DarrylBurke; 04-28-2012 at 04:59 PM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: help

    No one is going to write this for you of course, but we'll be more than glad to help. You should
    • Show us what you've done so far
    • Show us any compilation errors, exception stacktraces, or any other error messages
    • Explain any misbehaviors from your code
    • Ask meaningful and specific questions about things you're unsure of.


    Do this and you'll likely get lots of help.

    Luck.

  4. #4
    jack18 is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: help

    I'm not good on java .that's what i done ... i having 2 error ..

    import java.io.*;
    import java.util.*;

    public class FilterStream
    {
    public static void main(String[] args)
    {



    Scanner input =new Scanner(System.in);
    String name=input.next();
    int number=input.nextInt();

    try
    {
    FileOutputStream fos = new FileOutputStream("studentinfo.txt");
    DataOutputStream dos = new DataOutputStream(fos);
    dos.writeInt(number);
    dos.writeUTF(name);
    dos.flush();
    dos.close();

    FileInputStream fis = new FileInputStream("studentinfo.txt");
    DataInputStream dis = new DataInputStream(fis);

    ////// I need here two output two different variable at the same time on a same line how ??
    int Id = dis.readInt();
    System.out.println(" Id: " + Id);
    String name = dis.readUTF();
    System.out.println(" Name: " + name);

    }
    catch (IOException e)
    {
    e.printStackTrace();
    }
    }
    }
    Last edited by jack18; 04-28-2012 at 05:53 PM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: help

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •