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.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Fantastisk!
Completion rate forbedret til 1.52
Challenge: Operators
Sveip for å vise menyen
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.
Løsning
Takk for tilbakemeldingene dine!
single