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.
Soluzione
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Fantastico!
Completion tasso migliorato a 1.52
Challenge: Operators
Scorri per mostrare il 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.
Soluzione
Grazie per i tuoi commenti!
single