大家好,我是初学者,这是我的第3个代码。 基本上,每当控制台向我显示力值时,我都希望它问我“什么是新质量”或类似的东西,或者一遍又一遍地重复相同的过程。谢谢
public static void main(String[] args) {
int force;
double Acceleration;
double Mass;
NewInput();
{
Scanner myScanner = new Scanner(System.in);
System.out.print("What is a given Mass");
Mass = myScanner.nextDouble();
}
Acceleration = 9.8;
force = (int)(Mass*Acceleration);
if(force < 0)
throw new IllegalArgumentException("Must be > 0!");
System.out.print("Gravitational force for given mass is ");
System.out.print(force);
if (force > 1)
System.out.println(" Newtons");
else System.out.println("Newton");
}
private static void NewInput() {
// TODO Auto-generated method stub
}
}