Challenge: Income Tax Calculation
Oppgave
Swipe to start coding
Implement a program that calculates taxes based on income brackets, applying different tax rates depending on the income level.
- If the income is over 100,000, the tax rate is 25%.
- If the income is between 50,000 and 100,000, the tax rate is 15%.
- If the income is below 50,000, the tax rate is 5%.
- Set the appropriate values in
ifandelse iffor the income conditions. - Multiply the amount by the appropriate percentage in each case to get the correct tax amount.
- In the
calculateTaxes()method, iterate through theincomesarray using afor-eachloop. - Add the tax for each income to the
resultlist using theadd()method and thetaxFunction.apply()functional interface passed as a parameter. - Store the result of the
calculateTaxes()method in thetaxesvariable.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 7
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
Fantastisk!
Completion rate forbedret til 2.33
Challenge: Income Tax Calculation
Sveip for å vise menyen
Oppgave
Swipe to start coding
Implement a program that calculates taxes based on income brackets, applying different tax rates depending on the income level.
- If the income is over 100,000, the tax rate is 25%.
- If the income is between 50,000 and 100,000, the tax rate is 15%.
- If the income is below 50,000, the tax rate is 5%.
- Set the appropriate values in
ifandelse iffor the income conditions. - Multiply the amount by the appropriate percentage in each case to get the correct tax amount.
- In the
calculateTaxes()method, iterate through theincomesarray using afor-eachloop. - Add the tax for each income to the
resultlist using theadd()method and thetaxFunction.apply()functional interface passed as a parameter. - Store the result of the
calculateTaxes()method in thetaxesvariable.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 7
single