正如标题中所说,我在代码的等式部分得到了一个非法的表达式开头。我确实相信我把一切都说对了,但我仍然有一个非法的表达开始。
public class FacebookUsers
{
public static void main(String[] args)
{
int months = 1;
for ( int people = 500000000; people < 2000000000; months ++)
{
people = (peoplestart) * ((1.05)**(months));
}
System.out.println("It took "+months+" to reach one billion users on "
+ "facebook at the rate of 5% growth.");
months = 1;
for ( int people = 500000000; people < 2000000000; months ++)
{
people = people * ((1.05)**(months));
}
System.out.println("It took "+months+" to reach two billion users on "
+ "facebook at the rate of 5% growth.");
}
}
如有任何帮助,我们将不胜感激,并提前向您表示感谢。
Java没有**
运算符。使用java.lang.Math.pow
。
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html