Decisions if Problems

Problem 1

print("Problem 1")

Write Lua code that ask the user for a number. Write if statements to determine:

  • Is the number positive?

  • Is the number negative?

  • Is the number 0?

Print the number and whether it is positive, negative or 0. Test your code on positive and negative numbers.

Problem 2

print("Problem 2")

Write Lua code that asks the user what city Roblox is headquartered in. If the user enters, San Mateo, print "Correct!". If the user does not enter San Mateo, print "Incorrect!"

Problem 3

print("Problem 3")

Write Lua code that asks the user what year Roblox was founded. If the user enters 2006, print "Correct!". If the user does not enter 2006, print "Incorrect!"

Problem 4

print("Problem 4")

Create a variable named roblox and ask the question, “do you want to play roblox”.

You want extra credit so you play Roblox with Mr Cheng’s daughter so you make the logical choice.

If the user inputs “yes” print “good choice”. If the user inputs “no”, print “Mr Cheng’s daughter will be very disappointed”

Problem 5

print("Problem 5")

She plays Work at a Pizza Place and earns 200 robux.

Create a variable called robux and assign it the value 200.

She plays for a few more hours and earns 50 Robux for each hour she plays.

Ask the user how many hours she plays.

Add the initial amount she earned with the additional amount she made.

Print the total amount of Robux.

Problem 6

print("Problem 6")

Ask the user, do you hear Laurel or Yanny?

If the user enters “Laurel”, print “doesn’t it sound like Yanny?”.

If the user enters “Yanny”, print “doesn’t it sound like Laurel?”

Problem 7

print("Problem 7")

Ask the user to enter an abbreviation.

  • If the user enters "lol", print "laughing out loud".

  • If the user enters "rofl", print "rolling on the floor laughing".

  • If the user enters "lmk", print "let me know".

  • If the user enters "smh", print "shaking my head".

Problem 8

print("Problem 8")

Ask the user, what is the net worth of Mark Zuckerberg. (do not enter commas when entering the number)

If the user enters 54500000000, print “yes and that’s a 54.5 billion”. If the user enters less than 54500000000, print “he has more money than that”. If the user enters more than 54500000000, print “that’s too little”.

Problem 9

print("Problem 9")

Ask the user for a month.

Display the number of days in the month. Print "28 or 29 days" for February.

Problem 10

print("Problem 10")

Ask the user for the number of sides of a polygon.

Display the name of the polygon for sides from three to ten.