Challenge: Operators
Swipe to start coding
-
You are creating a simple store calculator. The calculator should compute the total price, discount, tax, and final price for items in a store.
-
Complete the
RunStoreCalculatormethod by filling in the missing parts (___) to correctly calculate:-
To calculate the total price, multiply the
priceof a single item by thequantityof items. -
To calculate the discount amount, multiply the
totalPricebydiscountPercentand then divide by 100 to convert the percentage into a value. -
To calculate the tax amount, first subtract the
discountAmountfrom thetotalPriceto get the price after discount, then multiply bytaxPercentand divide by 100. -
To calculate the final price, subtract the
discountAmountfrom thetotalPrice, then add thetaxAmountto get the final total the customer needs to pay.
-
-
Print all values with clear labels inside the method.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Awesome!
Completion rate improved to 1.52
Challenge: Operators
Swipe to show menu
Swipe to start coding
-
You are creating a simple store calculator. The calculator should compute the total price, discount, tax, and final price for items in a store.
-
Complete the
RunStoreCalculatormethod by filling in the missing parts (___) to correctly calculate:-
To calculate the total price, multiply the
priceof a single item by thequantityof items. -
To calculate the discount amount, multiply the
totalPricebydiscountPercentand then divide by 100 to convert the percentage into a value. -
To calculate the tax amount, first subtract the
discountAmountfrom thetotalPriceto get the price after discount, then multiply bytaxPercentand divide by 100. -
To calculate the final price, subtract the
discountAmountfrom thetotalPrice, then add thetaxAmountto get the final total the customer needs to pay.
-
-
Print all values with clear labels inside the method.
Solution
Thanks for your feedback!
single