正如标题中所说,我在代码部分的代码中得到了非法的表达式。我相信我把所有东西都放在了正确的位置,但我仍然得到一个非法的表达。
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.");
}
}
感谢任何帮助,并提前感谢您。
答案 0 :(得分:9)
Java没有**
运算符。使用java.lang.Math.pow
。
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html