Skip to content

Instantly share code, notes, and snippets.

@ir-g
Last active November 3, 2015 14:20
Show Gist options
  • Save ir-g/bf68db6cd4373419c382 to your computer and use it in GitHub Desktop.
Save ir-g/bf68db6cd4373419c382 to your computer and use it in GitHub Desktop.
If Statement Tasks
###
A text box, or other control, can be used to enter the temperature of the room.
Below 16 degrees should result in a message, or a label, saying it is too cold to work.
###
temp = prompt "Temp?"
if temp < 16 then alert "Too cold" else alert "All good"
###
A text box, or other control, can be used to enter the temperature of the room.
Below 16 degrees should result in a message, or a label, saying it is too cold to work.
###
temp = prompt "Temp?"
if temp < 16
alert "Too cold"
else if temp > 25
alert "Too Hot"
else
alert "All good"
###
A text box, or other control, can be used to enter the temperature of the room.
Below 16 degrees should result in a message, or a label, saying it is too cold to work.
###
temp = prompt "Temp?"
if temp < 0
alert "Freezing"
else if temp < 16
alert "Too cold"
else if temp > 50
alert "Too Hot to live"
else if temp > 25
alert "Too Hot"
else
alert "All good"
###
Income tax is payable at different rates depending on your earnings. Up to £10,600, you pay no tax. Then up to £42,385, you pay 20% tax. Then up to £150,000, you pay 40% tax. Above £150,000, you pay 45% tax. Write a program to display a person’s tax rate based on their income.
###
wage = prompt "Wage?"
tax = 0;
if wage <= 10600
alert "No tax"
else if wage <= 42385
alert "20% tax"
else if wage <= 150000
alert "40% tax"
else
alert "45% tax"
###
Income tax is payable at different rates depending on your earnings. Up to £10,600, you pay no tax. Then up to £42,385, you pay 20% tax. Then up to £150,000, you pay 40% tax. Above £150,000, you pay 45% tax. Write a program to display a person’s tax rate based on their income.
###
wage = prompt "Wage?"
rWage = wage
tax = 0;
if wage <= 10600
alert "No tax"
else if wage <= 42385
rWage -= 10600
tax = rWage * 0.2
alert "20% tax"
alert "Taxed £#{tax}"
else if wage <= 150000
rWage -= 10600
tax += (150000-(10600+42385))*0.2
rWage = wage - 42385
tax += rWage * 0.4
alert "40% tax"
alert "Taxed £#{tax}"
else
rWage -= 10600
tax += (150000-(10600+42385))*0.2
rWage = wage - 42385
tax += rWage * 0.4
rWage = wage - 150000
tax += rWage * 0.45
alert "45% tax"
alert "Taxed £#{tax}"
###
Income tax is payable at different rates depending on your earnings. Up to £10,600, you pay no tax. Then up to £42,385, you pay 20% tax. Then up to £150,000, you pay 40% tax. Above £150,000, you pay 45% tax. Write a program to display a person’s tax rate based on their income.
###
pc00 = 10600
pc20 = 42385
pc40 = 150000
wage = prompt "Wage?"
rWage = wage
tax = 0;
if wage <= pc00
alert "No tax"
else if wage <= pc20
rWage -= pc00
tax = rWage * 0.2
alert "20% tax"
alert "Taxed £#{tax}"
else if wage <= 150000
tax += (pc20-pc00)*0.2
rWage = wage - pc20
tax += rWage * 0.4
alert "40% tax"
alert "Taxed £#{tax}"
else
tax += (pc20-pc00) * 0.2
tax += (pc40-pc20) * 0.4
rWage = wage - pc40
tax += rWage * 0.45
alert "45% tax"
alert "Taxed £#{tax}"
###
Income tax is payable at different rates depending on your earnings. Up to £10,600, you pay no tax. Then up to £42,385, you pay 20% tax. Then up to £150,000, you pay 40% tax. Above £150,000, you pay 45% tax. Write a program to display a person’s tax rate based on their income.
###
pc00 = 10600
pc20 = 42385
pc40 = 150000
wage = prompt "Wage?"
rWage = wage
tax = 0;
if wage > 100000
xwage = wage - 100000
z = Math.floor(xwage / 2)
if pc00 - z <= 0 then pc00 = 0
if pc20 - z <= 0 then pc20 = 0
if pc40 - z <= 0 then pc40 = 0
if wage <= pc00
alert "No tax"
else if wage <= pc20
rWage -= pc00
tax = rWage * 0.2
alert "20% tax"
alert "Taxed £#{tax}"
else if wage <= 150000
tax += (pc20-pc00)*0.2
rWage = wage - pc20
tax += rWage * 0.4
alert "40% tax"
alert "Taxed £#{tax}"
else
tax += (pc20-pc00) * 0.2
tax += (pc40-pc20) * 0.4
rWage = wage - pc40
tax += rWage * 0.45
alert "45% tax"
alert "Taxed £#{tax}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment