Results 1 to 3 of 3
  1. #1
    aznmanjj is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Assignment help!!!!! PLEASE!

    Ok, so with a given numbers.dat file, my assignment is to have the
    program read the file and generate three random integers from the numbers.dat file. this is my code so far:
    How would I fix this so that my program can generate the numbers? any tips?

    //Random Numbers

    import java.util.Random;
    import java.util.Scanner;

    class RandomNumbers{
    public static void main(String[] args){
    Scanner reader = new Scanner(new File("numbers.dat"));
    PrintWriter writer = new PrintWriter(new File("numbers.dat"));

    Random rice = new Random();
    int number;

    for(int counter=1; counter<=3; counter++){
    number = rice.nextInt(99);
    System.out.println(number + "Yes, the number is there");

    What does this mean? unreported exception; must be caught or declared to be thrown
    Scanner reader = new Scanner(new File("numbers.dat"));

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Assignment help!!!!! PLEASE!

    What did you start another thread? What was wrong with asking more questions in your first thread?

    The error message gives you all the information you need. The exception must be caught or declared to be thrown. Somewhere in your code you are making a call to a method or construtor that throws a FileNotfoundException. Therefore your code needs to handle that exception (should it get thrown). If you do not understand this then you need to revise "Exception Handling".

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Assignment help!!!!! PLEASE!

    Please have a look at these two tutorials on exceptions: What is an Exception? and Catching and Handling Exceptions

    Also, please make your forum question headings more informative and less !!!! Of course you need help, else you wouldn't post a question. Better to think of the question heading as similar to the a newspaper article's headline -- it briefly summarizes the article (or in your case, the problem) below it. This way folks opening your question will have a quick idea of what to expect and if they can help you or not.

Similar Threads

  1. HW assignment help
    By mackavelirip in forum New To Java
    Replies: 5
    Last Post: 03-31-2011, 03:34 AM
  2. assignment help
    By xyknight in forum New To Java
    Replies: 6
    Last Post: 03-13-2011, 07:19 PM
  3. Need help with a assignment
    By helpMe.Java in forum New To Java
    Replies: 7
    Last Post: 06-06-2010, 04:49 PM
  4. I am looking for help with an assignment
    By nanoo51969 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 09:41 PM

Posting Permissions

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