aspose file tools*
The moose likes Beginning Java and the fly likes Assignment help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Assignment help

Jay Jeong
Greenhorn

Joined: Nov 16, 2011
Posts: 6
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"));
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Let's continue the topic here:

http://www.coderanch.com/t/559347/java/java/AP-Computer-Science-assignment-help
 
jQuery in Action, 2nd edition
 
subject: Assignment help