Erik Price
Posts: 39
Nickname: erikprice
Registered: Mar, 2003
|
|
Re: projectDue = HELP;
|
Posted: May 5, 2003 6:05 AM
|
|
> Could someone critique this Please!!
public class Convert1 {
public static void main(String[] args) {
int feet = 12;
int yard = 3 feet;
int mile = 1760 yard;
System.out.println("The total distanc is " " + "" + ");
}
}
Well, you've got a class with a main method, so you can execute this class. But it doesn't do anything. You've declared some integer variables and initialized them to values, which is nice, but the syntax isn't really correct -- you can't put "feet" or "yard" after an integer in the code, because the compiler has no idea what you mean by this. Finally, you have a System.out.println statement which also won't compile, because your quotes don't appear to be balanced.
I'll give you three hints:
1. You can make a variable assignment using another variable's value, like this:
int quart = 32;
int gallon = 4 * quart;
2. The System.out.println method takes a single argument. You can build up a single argument by adding primitives together, or by concatenating String objects together, or by combining both techniques. Either way, you need to end up with a single value that becomes the argument to println .
3. Instead of hardcoding a value into your source code, you can pass it into the program at runtime (after you've compiled it, when you're executing it) as an argument to your command in the shell/DOS prompt. But you will need to refer to this argument somehow from within your program. Big hint: there's a reason that the String[] argument to the main method is often called "args".
I hope these pointers will help show the way, or at least provide you with some keywords that you can use to research the solutions. Good luck.
|
|