Post Reply 
Help With Java
Author Message
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #1
Help With Java
Spoiler:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.*;

public class SpeedCam
{
	private static final String FILE_SPEC0 = "C://camera0_test1.dat";
	private static final String FILE_SPEC1 = "C://camera0_test2.dat";
	private static final int SPEED_LIMIT = 50;

	public static void processData()
	{
		FileInputStream fis;
		DataInputStream dis;
		FileOutputStream fos;
		DataOutputStream dos;
		String regNum;
		int Time1;
		int Time2;
		int Time3;
		String VehicleType;
		
		try
		{
			fis = new FileInputStream(FILE_SPEC0);
			dis = new DataInputStream(fis);
			fos = new FileOutputStream(FILE_SPEC1);
			dos = new DataOutputStream(fos);

			while(true)
			{
				try
				{
					regNum = dis.readUTF();
					Time1 = dis.readInt();
					Time2 = dis.readInt();
					Time3 = dis.readInt();
					VehicleType = dis.readUTF();
					System.out.print(regNum+"\t"+Time1+"\t"+Time2+"\t"+Time3+"\t"+VehicleType);
					
				}
				catch(Exception e)
				{
					fis.close();
					fos.close();
				}
			}
		}
		catch(Exception e)
		{
		}
	}

	public static void main(String[] args)
	{
		processData();
	}
}

I don't have even the vaugest idea what's wrong with this, but its flat out refusing to print. The file exists, and supposedly contains relevant information, although i can't confirm this. Does anyone have enough experience to be able to guide me down the right path so i can get started on this application

(This post was last modified: 27/11/2009 08:59 AM by roberth.)
27/11/2009 08:58 AM
Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #2
RE: Help With Java
Ignore this, Time3 didnt exist and removing it solved the issues. Crappy programming lecturer

27/11/2009 09:01 AM
Find all posts by this user Quote this message in a reply
boogschd
boogyman
Worlds End

Posts: 4,954.3196
Threads: 90
Joined: 29th Nov 2007
Reputation: 4.19708
E-Pigs: 43.6852
Offline
Post: #3
RE: Help With Java
lolz .. couldnt help anyway :p .. lost all my java knowledge :p
27/11/2009 09:02 AM
Visit this user's website Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #4
RE: Help With Java
boogschd Wrote:lolz .. couldnt help anyway :p .. lost all my java knowledge :p

lol. unfortunately I pretty much did too. :p

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
27/11/2009 11:11 AM
Visit this user's website Find all posts by this user Quote this message in a reply
trademark91
Unique?
Fractal Insanity

Posts: 4,718.4965
Threads: 269
Joined: 4th Jan 2008
Reputation: -6.15982
E-Pigs: 105.8691
Offline
Post: #5
RE: Help With Java
java is the evilsauce. it exists soley to make my life miserable.

[Image: 531115][Image: 76561198014212040.png]
windows Proud
27/11/2009 11:15 AM
Find all posts by this user Quote this message in a reply
LumpiaWarrior
chef d(^.^)b

Posts: 508.2504
Threads: 40
Joined: 6th Nov 2009
Reputation: -7.31666
E-Pigs: 22.2371
Offline
Post: #6
RE: Help With Java
Like I said, CS = my worst enemy

██████████████▄▐█▄▄▄▄█▌
██████▌▄▌▄▐▐▌███▌▀▀██▀▀
████▄█▌▄▌▄▐▐▌▀███▄▄█▌
▄▄▄▄▄██████████████


BDSM, LOLI, DESU, BACON, WoW

Spoiler for Story of My life:
Quote:I'm 20 and I was a computer/electrical engineer major. I was into my third year and I had a year and a half to go.

Then 1 day as I am doing my programming homework and figuring out what the hell was wrong with my code,

I thought to myself 'spoon, i don't want to do this for the rest of my life.'

So I changed majors and now I am a proud music (vocal) education major. The point is do what you want to do in life. Cause its your life don't let anyone hold you back.
27/11/2009 11:18 AM
Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #7
RE: Help With Java
./xitherun.sh Wrote:
boogschd Wrote:lolz .. couldnt help anyway :p .. lost all my java knowledge :p

lol. unfortunately I pretty much did too. :p

I never had any, but i have to write a confusing program, so expect a couple of these XD

27/11/2009 11:23 AM
Find all posts by this user Quote this message in a reply
Hellgiver
Team Ramrod

Posts: 1,875.3073
Threads: 230
Joined: 27th Sep 2007
Reputation: 2.15096
E-Pigs: 57.9774
Offline
Post: #8
RE: Help With Java
Lulz, same here. Though I am not as far as you are. I have to write a Tic-tac-toe program within the next week for homework XD

Hardcore!

[Image: toocool.png]
<3 Diego!
27/11/2009 02:47 PM
Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #9
RE: Help With Java
MOAR HALP TIEM!!!!


Im screwed. i can't make this program output index, and its absolutely killing me. Not supposed to fix any errors unless theyre syntax, so that's not what needs sorting...just a couple of lines to make it run

Anyone can help
Spoiler:
import java.util.Scanner;

public class Annex1 {


	
    private static String calcIndex(int gr, int wo, int con)
    {
	
String index = "";
	
boolean ok = true;
	
String index1;
	
String index2;
	
String index3;

	


	
if(gr < 1 || gr > 8)
	
{
	
    ok = false;
	
}
	
if(con < 1 || con > 4)
	
{
	
    ok = false;
	
}
	
if(!ok)
	
{
	
    index = "ZZZZ";
	
}
	
else
	
{
	
    index1 = g_value(gr);
	
    index2 = w_value(wo);
	
    index3 = r_value(con);
	
    index = index1 + index2 + index3;
	
}
	
return index.toString();
	
}

	
    
	
    
    private static String g_value(int gr)
    {
	
Integer i = new Integer(gr);
	
return i.toString();
    }

    private static String w_value(int wo)
    {
	
int val;
	
Integer i;

	
if(wo < 500)
	
{
	
    val = 0;
	
}
	
else if(wo ≤ 1000)
	
{
	
    val = 1;
	
}
	
else if(wo < 2500)
	
{
	
    val = 2;
	
}
	
else
	
{
	
    val = 4;
	
}
	
i = new Integer(val);
	
return i.toString();
    }

    private static String r_value(int con)
    {
	
Integer i = new Integer(con);
	
return i.toString();
    }
    
	


    
	
/**
	
* @param args
	
*/
	
public static void main(String[] args) {
	
	
Scanner scanner = new Scanner(System.in);
	
	
int gr = scanner.nextInt();
	
	
int con = scanner.nextInt();
	
	
int wo = scanner.nextInt();
	
	
calcIndex(gr,con,wo);
	
	

	
}

}

(This post was last modified: 03/02/2010 03:44 AM by roberth.)
03/02/2010 03:43 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #10
RE: Help With Java
Output, as in, display the result of calcIndex to the console?
If so, you should change

Java Code
calcIndex(gr,con,wo);

to

Java Code
System.out.println(calcIndex(gr,con,wo));

or whatever the proper Java functions are.

(This post was last modified: 03/02/2010 03:56 AM by ZiNgA BuRgA.)
03/02/2010 03:55 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: