A customer can only order two types of beverages from the BucksStar coffee shop. The two types are Latte and Mocha. A cup of Latte is $2.07 and a cup of Mocha is $3.69. But this price applies only when it is not in the evening. In the evening, the price for a cup of Latte and Mocha are each reduced by a dollar. Write the following method that returns the total price of an order. getOrderPrice(true, 1, 1) → 3.76 getOrderPrice(false, 1, 1) → 5.76 getOrderPrice(true, 2, 2) → 7.52 getCoffeeOrderPrice(true, 1, 1) → 3.76 getCoffeeOrderPrice(false, 1, 1) → 5.76 getCoffeeOrderPrice(true, 2, 2) →
public double getCoffeeOrderPrice(boolean evening, int latte, int mocha) { if ( evening == true ) { return 3.76; } else { return 5.76 ; } }
latte_price = 2.07 mocha_price = 3.69 if ( evening == true ) { return latte * (latte_price - 1) + mocha * (mocha_price - 1) } else { return latte * latte_price + mocha * mocha_price }
Of course you would likely have to declare the first two variables as floats or just put the numbers in where I used the variables and I also missed the semicolons. Been doing mostly python, no semicolons or typecasting variables needed.
Thanks!
Join our real-time social learning platform and learn together with your friends!