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.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Incrível!
Completion taxa melhorada para 1.52
Challenge: Operators
Deslize para mostrar o 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.
Solução
Obrigado pelo seu feedback!
single