Blitzman
Blitzman

Reputation: 11

jGRASP (Java) entering a formula in java

I input this into java and these errors come out. error ")" expected, error not a statement , and error ";" expected. but i do not understand why?

  pent = n(3n-1)/2;

Upvotes: 0

Views: 82

Answers (1)

Scary Wombat
Scary Wombat

Reputation: 44854

In java this would be

double pent = n * (3.0 * n - 1.0) / 2.0;

Upvotes: 1

Related Questions