D
Dave
The program below takes an argument entered at the command line and
simply returns a float variable and then an integer.
public class Changer {
public static void main(String[] arguments) {
if (arguments.length > 0) {
System.out.println("The original value: "
+ arguments[0]);
Float num1 = new Float(arguments[0]);
float num2 = num1.floatValue();
int num3 = (int)num2;
System.out.println("The final value: " + num3);
}
}
}
Now let's say I want to input the argument at the command line, but
rather than doing, say:
C:>java Changer 7 (i.e. entering the argument on the command line
itself) ...
I want the program to request, and then process, the input using the
readLine() method, as follows:
C:> java Changer
> Type a number, please.
> ... and so on ...
My questions are:
(1) What's the syntax I need in order to implement the permutation of
readLine() that I want?
(2) What lines of code must I add to the program and where?
Thanks,
Dave
simply returns a float variable and then an integer.
public class Changer {
public static void main(String[] arguments) {
if (arguments.length > 0) {
System.out.println("The original value: "
+ arguments[0]);
Float num1 = new Float(arguments[0]);
float num2 = num1.floatValue();
int num3 = (int)num2;
System.out.println("The final value: " + num3);
}
}
}
Now let's say I want to input the argument at the command line, but
rather than doing, say:
C:>java Changer 7 (i.e. entering the argument on the command line
itself) ...
I want the program to request, and then process, the input using the
readLine() method, as follows:
C:> java Changer
> Type a number, please.
> ... and so on ...
My questions are:
(1) What's the syntax I need in order to implement the permutation of
readLine() that I want?
(2) What lines of code must I add to the program and where?
Thanks,
Dave