This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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: 3647

Let's continue the topic here:
GeeCON Prague 2014
subject: Assignment help