S
summer_haven
hello all..
im new to java, starting year one next year in university and going
through some questions that have been used in the past for newbies..
i need help on a command line question. basically i have written a
program (works on textpad) but wish for it to run on command prompt
(windows xp) so that i simply type:
java calculation 0 10.0 2 ... so it outputs the answer (in this case
5.0). however after attempting this, only error messages appear
(NoClassDefFoundError:calculation)
here is the code:
import java.util.Scanner;
import java.io.*;
public class Calculation {
public static void main (String[]args)
{
for (int i = 0; i < args.length; i++)
System.out.println(args);
Scanner in = new Scanner(System.in);
System.out.println("Please Enter Velocity - in meters");
double v = in.nextDouble();
System.out.println("Please Enter velocity - in meters/seconds");
double u = in.nextDouble();
System.out.println("Please Enter Time - in seconds");
double t = in.nextDouble();
{
System.out.println("The acceleration is " + ((v-u)/t));
}
}
}
thanks for any help!
Sara
im new to java, starting year one next year in university and going
through some questions that have been used in the past for newbies..
i need help on a command line question. basically i have written a
program (works on textpad) but wish for it to run on command prompt
(windows xp) so that i simply type:
java calculation 0 10.0 2 ... so it outputs the answer (in this case
5.0). however after attempting this, only error messages appear
(NoClassDefFoundError:calculation)
here is the code:
import java.util.Scanner;
import java.io.*;
public class Calculation {
public static void main (String[]args)
{
for (int i = 0; i < args.length; i++)
System.out.println(args);
Scanner in = new Scanner(System.in);
System.out.println("Please Enter Velocity - in meters");
double v = in.nextDouble();
System.out.println("Please Enter velocity - in meters/seconds");
double u = in.nextDouble();
System.out.println("Please Enter Time - in seconds");
double t = in.nextDouble();
{
System.out.println("The acceleration is " + ((v-u)/t));
}
}
}
thanks for any help!
Sara