confusedMind
confusedMind

Reputation: 2653

Having issue writing a mathematical equation

Stuck on how to perform a simple line formula as below:

double profit=0;
double totalPrice=19.25;
int cost = 12;

profit = totalPrice - 2.15(totalPrice * 15 %) - (cost);

How can I write the above equation in code I never have done it before it is giving error on 2.15 and 15%. How do I represent those numbers?

Thank you

Upvotes: 0

Views: 117

Answers (2)

dcaswell
dcaswell

Reputation: 3167

profit = totalPrice - 2.15 * (totalPrice * 0.15) - (cost);

15% is expressed as 0.15.

Upvotes: 3

squillman
squillman

Reputation: 13641

profit = totalPrice - (2.15 * (totalPrice * .15)) - cost;

Upvotes: 3

Related Questions