2

正如标题中所说,我在方程式部分的代码中得到了非法的表达式开头。我确实相信我把一切都做对了,但我仍然有一个非法的表达开始。

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.");

   }

}

任何帮助表示赞赏,并提前感谢您。

4

1 回答 1

9

Java 没有**运算符。使用java.lang.Math.pow.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

于 2013-02-14T16:41:27.870 回答