Results 1 to 3 of 3
Thread: Assignment help!!!!! PLEASE!
- 11-21-2011, 12:04 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
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.io.*;
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?
RandomNumbers.java:12: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
Scanner reader = new Scanner(new File("numbers.dat"));
- 11-21-2011, 12:08 AM #2
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".
-
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
-
HW assignment help
By mackavelirip in forum New To JavaReplies: 5Last Post: 03-31-2011, 03:34 AM -
assignment help
By xyknight in forum New To JavaReplies: 6Last Post: 03-13-2011, 07:19 PM -
Need help with a assignment
By helpMe.Java in forum New To JavaReplies: 7Last Post: 06-06-2010, 04:49 PM -
I am looking for help with an assignment
By nanoo51969 in forum New To JavaReplies: 1Last Post: 03-23-2009, 09:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks