Question:
how do i run this java program in cmd?
Mak G
2010-07-25 06:51:27 UTC
class oneVariable
{
public void sin(double a)
{
double b = Math.sin(a);
System.out.println(b);
}
public void cos(double c)
{
double d = Math.cos(c);
System.out.println(d);
}
public void tan(double e)
{
double f = Math.tan(e);
System.out.println(f);
}
public void asin(double g)
{
double h = Math.asin(g);
System.out.println(h);
}
public void acos(double i)
{
double j = Math.acos(i);
System.out.println(j);
}
public void atan(double k)
{
double l = Math.atan(k);
System.out.println(l);
}
public void exp(double m)
{
double n = Math.exp(m);
System.out.println(n);
}
public void pow(double o, double op)
{
double p = Math.pow(o,op);
System.out.println(p);
}
public void log(double q)
{
double r = Math.log(q);
System.out.println(r);
}
public void sqrt(double s)
{
double t = Math.sqrt(s);
System.out.println(t);
}
public void ceil(double u)
{
double v = Math.ceil(u);
System.out.println(v);
}
public void floor(double w)
{
double x = Math.floor(w);
System.out.println(x);
}
public void rint(double y)
{
double z = Math.rint(y);
System.out.println(z);
}
public void round(double ab)
{
double ba = Math.round(ab);
System.out.println(ba);
}
public void abs(double ac)
{
double bc = Math.abs(ac);
System.out.println(bc);
}
public void atan2(double ad, double we)
{
double bd = Math.atan2(ad,we);
System.out.println(bd);
}
public void max(double ae, double rf)
{
double be = Math.max(ae, rf);
System.out.println(be);
}
public void min(double af, double fv)
{
double bf = Math.min(af, fv);
System.out.println(bf);
}
}
Four answers:
Prabh Pal Singh
2010-08-01 02:18:27 UTC
you cannot run this Program in java as it doesn't have static void main() method

use it as package class to call functions when needed

if you still want to run it add thos code in it

public static void main(String args[])

{

sin(45.00);

cos(60.00);

tan(30.00);

.

.

.

}
Heershreck
2010-07-25 14:02:01 UTC
In order to run a Java program, it requires a Main function (public static void main(String[] args){}). This program does't have one. However, this isn't a program that you should be running anyways. It contains functions that you might want to use in other programs. To use these functions, put this file (.java) in the same file as the rest of your project or import it.
Jimmy
2010-07-25 13:54:58 UTC
In order to RUN a program in java, it needs to have a "main" method, this program does not. Just keep this as a .java file in whatever directory you wish to use those methods and it will work out.
?
2010-07-25 13:55:16 UTC
First you have to compile it using javac and once you have the class file then you run it using:

java oneVariable.class


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...