For the love of god please help.

I think enforcing rules is a bit over-the-top considering this is just an informal forum based on halflife2 coding issues. I think once the sdk comes out and there are genuine hl2 coding posts, any off-topic threads will be closed. So until then it's just a case of ignoring/not helping.
 
yeah, maybe. but that didn't work very well in this case did it?
 
I agree with your idea Phisionary; there really should be a rule disallowing posts like this one. In most other coding forums it is a strictly enforced policy. After all, we're here to help each other out, and learn in the process. Threads like this certainly don't assist us in that regard. I know this is a HL2 site, but this forum is really more of a general purpose programming section as it stands right now and should follow the basic rules of a coding forum. Besides, it would probably be a good idea to start enforcing the rules here right now, and set the trend for when the SDK is released. I guarantee there will be posts like this one, only they will be asking for someone to write the code for weapon XXX, etc.
 
Jesus, I'm sorry. But as I've said before, I don't plan on going into coding. It's simply a course I have to take to meet the requirements of a university I've been longing to attend. My mind does not comprehend what C++ or Java is. Lines of code in front of me, no matter what I've read or learned, means nothing to me. It looks like another language to me (which it is.) You have to, as mature as you come across to be, understand that not everyone is capable of the things you are. Bert saw a man in need, and he was there for him. I think incredibly highly of him. I also think incredibly highly of mr chimp, who attempted to show me cool things you can do with java. I thank everyone who asked me if I had options. However, I can't appriciate someone who basically makes my post look like I did something wrong. Wrong to the teacher? Yes, however, he wronged first. He deliberately handed me a sheet of paper, and told me, make this into a program. Sat back and watched. For a week, (where you said 3 days was ample time), I read an entire online Java tutorial for idiots. I read it day in, and day out, and came out with nothing. I turned to you guys, and am incredibly grateful to those who helped. qckbeam your post was very much appriciated too. But please dont start knocking me as a lazy ****, you have to understand, not everyone can do what you can do. I will continue to try and understand java, and hope the next topic i make will be simply for someone to review my code and just give me some helpful hints. Until then, we'll see what happens eh? ;)
 
I get it, Guinny. But people can make awfully convincing stories for why they need some code done, and I feel that's unfair to those who do it themselves. Really, don't worry about it. I'm just suggesting a new policy if this issue crops up again.

And if your instruction was really that lacking, I'd complain to someone in charge. It definitely takes some getting used to if your a total code nUb. I had a bunch of trouble learning to program before I took classes on it. I'm not a great 'self-directed-learner', really. Conceptually, some things were just kicking my ass. It took me a week of misusing them to understand what the hell the point of a 'for' loop was. I use dozens of 'em now...

And, in case you do have any interest in learning java or whatever (just the fundamentals, even. trust me, an EE major will need at least programming fundamentals. It wont even hurt much), post a thread. I'll help as well as I can, as I'm sure everyone else will too...

Oh, and... you don't have to call me Jesus. ;)
yeah, i know, i'm an arrogant prick. lol.
 
Thanks alot. Well...if I could, even though it's berts work...it doesn't seem to work. I tried doing a number of things. For instance, the try catch method seemed to be causing an error. I tried taking it out, and apparently certain lines at the bottom of the code had errors. The errors weren't detailed.

So here is what I have now:

public class test
{

public static void main(String args[])
{
//the variables we need to hold data

double pricePackA;
int percentLeanA;

double pricePackB;
int percentLeanB;

String input;


{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//Ask the user to enter the values we need.
System.out.print("Price per pound of package A:");
input = in.readLine();

pricePackA=Double.parseDouble(input);
System.out.print("Percent lean package A:");
input = in.readLine();
percentLeanA=Integer.parseInt(input);

System.out.print("Price per pound of package B:");
input = in.readLine();
pricePackB=Double.parseDouble(input);
System.out.print("Percent lean package B:");
input = in.readLine();
percentLeanB=Integer.parseInt(input);


double resultA;
double resultB;

resultA=pricePackA*100/percentLeanA;
resultB=pricePackB*100/percentLeanB;

//print our findings
System.out.print("Package A cost per pound: "+resultA+"\n");
System.out.print("Package B cost per pound: "+resultB+"\n");

System.out.println("Package "+(resultA<resultB?"A":"B")+" is the best value.");
}
{

return;

}
 
Well, at this point I guess theres no point of not giving answers.
Worked for me with three changes:

Missing two '}'s (closing brace) at the end or the program.

The try/catch structure is required for the input statements. The exceptions must be handled by something.

put a 'try{' before all the input= statements. and put a '}catch (IOException ioeRef) {}' after them (i.e. before the 'double resultA;' declaration.

Lastly, when in the try catch block, the variables need to have a default value. I just faked it enough to get it working. put:
pricePackA=pricePackB=percentLeanA=percentLeanB=1;
into the 'catch' block (i.e. in between the {} )
 
guinny you said you were planning on going into electrical engineering? chemical engineer here, with lots of eletrical friends, and as far as i know they've had to do at least 2-3 courses of programming. i think you may want to research your desired field. i had to take a c++ course in my first year, failed it, and took it again. if you think things are going to get easier when you get into electrical engineering your sorely mistaken, be prepared to fail, and learn from your failures, because they're coming.
 
You may have to do ASM(asembler(sp?)) in electrical engineering, but if it's anything like A level electronics it will be outwieghed by the silly mathmatics.

Still if I can do it, most people can do it... or not as I apparantly live in an academic bubble and I'm not in University.

Anyway it's not too difficult if you start at the absolute basics then slowly work up. I don't think java is the best language to teach the absolute basics. I'd probably say C or C++ is the best as it allows you to make a simple program without using Objects and it's not pascal.
 
I'd recommend getting your hands dirty with C++. I think eveyone should have some experience with non-managed code (i.e. creating/deleting your own memory) and pointers and stuff - just so you have a better idea of what's going on than someone raised on VB and the like.
 
public class test
{

public static void main(String args[])
{
//the variables we need to hold data

double pricePackA;
int percentLeanA;

double pricePackB;
int percentLeanB;

{try

String input;


{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//Ask the user to enter the values we need.
System.out.print("Price per pound of package A:");
input = in.readLine();

pricePackA=Double.parseDouble(input);
System.out.print("Percent lean package A:");
input = in.readLine();
percentLeanA=Integer.parseInt(input);

System.out.print("Price per pound of package B:");
input = in.readLine();
pricePackB=Double.parseDouble(input);
System.out.print("Percent lean package B:");
input = in.readLine();
percentLeanB=Integer.parseInt(input);

}catch (IOException ioeRef) {pricePackA=pricePackB=percentL eanA=percentLeanB=1}

double resultA;
double resultB;

resultA=pricePackA*100/percentLeanA;
resultB=pricePackB*100/percentLeanB;

//print our findings
System.out.print("Package A cost per pound: "+resultA+"\n");
System.out.print("Package B cost per pound: "+resultB+"\n");

System.out.println("Package "+(resultA<resultB?"A":"B")+" is the best value.");
}
{

return;

}
}
}

I got four more errors. (I hate debugging :-P)


Hope this helps:

helpp.jpg


I'm thinking there's something wrong with my bracket placement? :-\
 
Code:
public class test {

	public static void main(String args[]) {

		//the variables we need to hold data
		double pricePackA;
		int percentLeanA;

		double pricePackB;
		int percentLeanB;

		String input;

		try {

			BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 

			//Ask the user to enter the values we need.
			System.out.print("Price per pound of package A:");
			input = in.readLine();

			pricePackA=Double.parseDouble( input);
			System.out.print("Percent lean package A:");
			input = in.readLine();
			percentLeanA=Integer.parseInt( input);

			System.out.print("Price per pound of package B:");
			input = in.readLine();
			pricePackB=Double.parseDouble( input);
			System.out.print("Percent lean package B:");
			input = in.readLine();
			percentLeanB=Integer.parseInt( input);

		} catch (IOException ioeRef) {
			pricePackA=pricePackB=percentLeanA=percentLeanB=1;
		}
		double resultA;
		double resultB;

		resultA=pricePackA*100/percentLeanA;
		resultB=pricePackB*100/percentLeanB;

		//print our findings
		System.out.print("Package A cost per pound: "+resultA+"\n");
		System.out.print("Package B cost per pound: "+resultB+"\n");

		System.out.println("Package "+(resultA<resultB?"A":"B")+" is the best value.");
	}
	{

		return;

	}
}

that should be it. refomatted to the way I like to do it.

Errors:

the 'try' went before '{' symbol
you can think of it as "try ... all this stuff between the { }"
that's the way braces are usually (always?) used in java.

there were some spaces in the middle of your variables. 'percentLeanA' i think it was.

and there was a missing semicolon at the end of that multiple-assignement line... you need a semicolon after all expressions under noraml circumstances.

also took out an extra pair or braces that didn't seem to be doing any thing. kinda like the ones around the 'return' statement. I dunno what's with that.

I can't gauruntee it will compile I don't have one at home...

P.S. ctrl-alt-printscreen will capture just the selected window. In case you have more compile errs.
 
I really doubt that assembly would be required at just about any school. it's just not a practical language for comercial work except in rare circumstances.

although for EE i guess it's possible. ASM level stuff is probably used for microcontrollers and similar tech...

I know for EE at my school (two years for AAS degree) two courses with MATLAB are required...
That programs not real tough. basically a slick and specialized type of C. i thought the one I took was fun (that's just me :))

the only other college I know anything about requires C++, and I think a course with Maple (a ME ex-techer of mine who works in the industry says he uses it almost exclusively. If you don't know, Maple is a symbolic math computation language type thing. Using symbolic variables in mathematics programming. I've not used it myself...)
 
Phis check your pm. ;)

Oh and that code did elimate most errors. There's just one left.

dsrf.jpg


Apparently because there's a space between the words?

When I put them together, I get 6 more errors. :eek:

Any clue what could be causing this?


btw: deadline - its due in like an hour lol.
 
Read the error message. ';' expected.

You need a ; between the statements "pricePackA=pricePackB=percent" and "LeanA=percentLeanB=1".
 
OK, weird. I look back at my post and I see spaces in the middle of that variable name. they weren't there when I pasted.... Something on the board is ****ing up the formatting.

therealescher, those two statements are supposed to be one. just need to remove the spaces...

As for it not compiling without the spaces and giving you more errors? I dunno. Sometimes one error the compiler finds early on will halt the compiling process and hide other potential errors later in the code. And you can get a ton of errors from one small problem sometimes, so the number of them doesn't make a huge difference...

of course, if it was due yesterday... oh well :p
sorry we couldn't get it working in time i guess..

btw, all this cut'n'pasting off the boards doesn't seem to do us any good. if you still want to get it working or whatever, and need to show your code... copy it as a 'txt' file and attach. less problems.

attached is the fixed format version that i tried posting earlier. again, i can't say it will compile, i don't have a compiler. gl.
 
Ah, I see how it was meant to be.

As a side note, the reason the board added the space is because it was too long. A lot of forums do that to prevent someone from breaking the layout by typing 238423984723 s's and making it thousands and thousands of pixels wide.
 
I'm a cs major, but I know a few EE majors here. They've to take 6 hours of C++ programming, and then a 4 hour class of programming a Motorola 68HC12 microcontroller in motorola's assembly language. Which is at least 10 hours ( I dunno about other courses, could be more ) So, as far as programming, I think it's safe to say you'll be doing more of it.
 
It is difficult to make a budget that spans several years, because prices are not stable. If you company needs 200 pencils per year, you cannot simply use this year’s price as the cost of pencils two years from now. Due to inflation the cost is likely to be higher than it is today. Write a program to gauge the expected cost of an item in a specified number of years. The program asks for the cost of the item, the number of years from now that the item will be purchased, and the rate of inflation. The program then outputs the estimated cost of the item after the specified period. Have the user enter the inflation rate as a percentage, like 5.6 (percent).


Lol. That's my new java project. Doesn't seem as hard. He wants it in a dialog box, guess I'll be using JOptionPane. Yes, I learned SOME things. Does anyone have some helpful hints as to how to go about this one? He wants me to use a for loop, and at least one constructor in my code. Anyone have some hints/tips to get me off the ground with this one?
 
figure out what kind of input you want to get from the user (and its type: int, double, etc.) and then figure out what kind of math you need to do to come up with the right answer.

I'm not sure what the for loop would be for....
well, I guess maybe you could apply the inflation rate to the dollar amount for each year's difference.

bit OT, but I dislike it when instructors impose an artificial constraint in an assignment... just pointless. well, i guess for the sake of simplicity it might make sense...

i wrote a program in one of my classes, the teacher wanted done in a bourne shell for loop (I.E. foreach style). I did it with math in 4 easy to understand lines... I did it with a for loop it took 28 lines that I couldn't understand...

oh well i guess you do learn something from it anyway :rolleyes:
 
It turned out with my first project, i was missing my imports. so when i added import java.io; the prog worked. just incase u were wondering how it turned out.
 
Well, I buddied up with him a little beforehand. He understands my predicament, and he gave me full credit. Can't thank you guys enough, especially phisonary. I'm really tryin hard on this one. I'm hoping to be posting my code up soon, I think I'm starting to actually understand this stuff. :) Figure I'll use this thread to get help and hints, so always be on the lookout here! (If you care :p)
 
Back
Top