File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Assignment help

Jay Jeong

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.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"));
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4628

Let's continue the topic here:

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: Assignment help
It's not a secret anymore!