我尝试运行我的代码,每次我执行 Aquarius Facilitator 时都会显示 0.000。它与 int 和 double 作为我的变量和导致我对 trunkaid 的回答的 int 有关吗?谢谢您的帮助
这是我的程序
public class JRambolus
{
public JRambolus(){}
public JRambolus(double A)
{
Lengtus = A;
}
public JRambolus(double A, int B)
{
Lengtus = A;
Actus = B;
}
//mutator
void SetLengtus( double A )
{
Lengtus = A;
}
//mutator
void SetActus(int A)
{
Actus = A;
}
//accessor
double GetLengtus()
{
return Lengtus;
}
//accessor
int GetActus()
{
return Actus;
}
//Facilitator
double Arius()
{
return 3*Lengtus+(1/2*Actus);
}
double Aquarius()
{
return 4/3*((1/2*Lengtus)+(2/5*Actus));
}
double Nebulus()
{
return (Math.pow(Lengtus,2)+Math.pow(Actus,3/2))*4/3;
}
//Memeber Varibales
private double Lengtus;
private int Actus;
}
这是我的调用程序
public class JShower
{
public static void main(String[] args)
{
JRambolus FullRambolus = new JRambolus();
//Calling out the the system
System.out.printf("%43s %4s %8.3f%n" ,"The Arius of FullRambolus is" ,"=", FullRambolus. Arius() );
System.out.printf("%46s %s %8.3f%n" ,"The Aquarius of FullRambolus is","=", FullRambolus.Aquarius() );
System.out.printf("%45s %2s %8.3f%n%n%n","The Lengtus of FullRambolus is" ,"=", FullRambolus.Nebulus () );
JRambolus DefaultRambolus = new JRambolus();
//Calling the Mutator From JRambolus
DefaultRambolus.SetLengtus(6);
DefaultRambolus.SetActus(3);
//Calling out to the system
System.out.printf("%46s %4s %8.3f%n","The Arius of DefaultRambolus is" ,"=", DefaultRambolus. Arius() );
System.out.printf("%49s %s %8.3f%n" ,"The Aquarius of DefaultRambolus is","=", DefaultRambolus.Aquarius() );
System.out.printf("%48s %2s %8.3f%n","The Nebulus of DefaultRambolus is" ,"=", DefaultRambolus.Nebulus () );
}
}