Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Java Help!

Thread Tools
 
Search this Thread
 
Old Nov 27, 2002 | 08:23 PM
  #1  
Scooby Snax's Avatar
Scooby Snax
Thread Starter
Scooby Regular
 
Joined: Apr 2002
Posts: 630
Likes: 0
Post

I have been working on this problem for the last few weeks and not got anywhere at all. What i am trying to do is make a lottery program that stores name, tel no and 4 lottery numbers to a txt file and then when the program is run it checks 4 numbers against the ones in the txt file.

So far i have got a program to work that checks a txt file for the lowest number when only 1 number is there (not 4) and i have another program which creates 4 random numbers.

What i have so far is below:


import java.io.*;
import javax.swing.*;

public class Super7 {

private static String[] punter_name = new String [20];
private static String[] tel_number = new String [20];
private static int selection[] = new int[30][4];
private static int linecount = 0;
private static int counter = 0;


public static void main(String[] args){

String fname = JOptionPane.showInputDialog("Enter your file name/path");

System.exit(0);
}
}

public static void process(String l)
{
if (counter >= 20){
System.out.println("Arrays are full!");
return;
}
if (linecount % 3 == 0) {
punter_name[counter] = i;
}
else if (linecount % 3 == 1) {
phone_number[counter] = i;
}
else {
StringTokenizer st = new StringTokenizer(s);
int j = 0;
while (st.hasMoreTokens()) {
***** [j] = Integer.parseInt (st.NextToken());
j++;
}
}

public static int readFile(String filenm) {
int count = 0;
FileReader fileread;
String line = "xxxx";
try {
fileread = new FileReader (filenm);
}
catch (IOException e) {
errorMessage ("Error unable to open the file");
return 0;
}
BufferedReader br = new BufferedReader (fileread);
while (line != null) {
try {
line = br.readLine();
if (line != null) {
process (line);
count ++;
}
}
catch (IOException e) {
errorMessage("Error unable to read the file");
line = null;
}
}
try {
br.close();
fileread.close();
}
catch (IOException e) {
errorMessage ("Error closing file");
}
return count;
}

public static void errorMessage (String m) {
JOptionPane.showMessageDialog (null, m, "Error",
JOptionPane.ERROR_MESSAGE);
}
}

for (int index=0;index< myLottoArray.length;index++)
{
myLottoArray[index] = (int)(Math.random()*49+1);
}

for(int counter=1;counter<myLottoArray.length;counter++ )
{
for(int index=0;index< myLottoArray.length -1;index++)
{
if (myLottoArray[index] > myLottoArray[index + 1])
{
int jumble = myLottoArray[index];
myLottoArray[index]= myLottoArray[index + 1];
myLottoArray[index + 1] = jumble;
}//end if

System.out.println("The Lottery Numbers are:");

for(int index=0;index< myLottoArray.length;index++)
{
System.out.print( + myLottoArray[index] + " ");
}
}

Obviosuly its a long way off working, the code i posted is the two programs combined. If anyone could help i would be very grateful and willing to pay whatever it takes. Or if you have some good hints that would be good.

Thank you
Reply
Old Nov 27, 2002 | 09:26 PM
  #2  
super_si's Avatar
super_si
Scooby Regular
 
Joined: Feb 2002
Posts: 7,951
Likes: 0
From: Lurkin Somewhere
Post

Im gonna have a bash, not programmed Java since June though.

Si
Reply
Old Nov 27, 2002 | 09:38 PM
  #3  
Scooby Snax's Avatar
Scooby Snax
Thread Starter
Scooby Regular
 
Joined: Apr 2002
Posts: 630
Likes: 0
Post

Cheers mate, anything you can help with will be great. Im just not getting anywhere and i have to show what i have on friday.
If you can help i am willing to pay. Im not sure if what i have done so far is along the right lines.

Cheers
Reply
Old Nov 28, 2002 | 08:38 AM
  #4  
super_si's Avatar
super_si
Scooby Regular
 
Joined: Feb 2002
Posts: 7,951
Likes: 0
From: Lurkin Somewhere
Post

Suppose half the troubles storing the data, im thinking linked list of the data, that way it cant be duplicated.

Reads in from file, all datas put in the linked list, then it can be added, amended etc

SI
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Fosters
Computer & Technology Related
6
Mar 17, 2003 04:27 PM
suba
Computer & Technology Related
3
Aug 23, 2002 10:45 PM
father_jack
Computer & Technology Related
3
Aug 14, 2002 11:13 AM
super_si
Computer & Technology Related
1
Apr 18, 2002 07:52 PM




All times are GMT +1. The time now is 10:45 AM.