Question 33: If Elif Minecraft

Objective:


Create a simple program that helps a player manage their emeralds when buying items in the Minecraft marketplace.


Steps:

Player Information:

  • Ask the user for their Minecraft player name and store it in a variable called player_name.

  • Ask the user how many emeralds they have at the start and store it in a variable called emeralds.

Item Purchases:

  • Ask the user how many emeralds they spent on weapons and store it in a variable called weapons.

  • Ask the user how many emeralds they spent on armor and store it in a variable called armor.

  • Ask the user how many emeralds they spent on food and store it in a variable called food.

  • Ask the user how many emeralds they spent on building blocks or decorations and store it in a variable called blocks.

Calculate Total Spent:

  • Create a variable to calculate the total emeralds spent by adding: weapons + armor + food + blocks.

Calculate Remaining Emeralds:

  • Create a variable to calculate the remaining emeralds by subtracting total spent from emeralds.

Check Budget Status:

  • Use if-elif-else statements to evaluate the remaining emeralds and provide feedback:

    • If remaining_emeralds is greater than 20:
      Print: "Nice shopping, [player_name]! You still have [remaining_emeralds] emeralds left. Save some for rare trades!"

    • If remaining_emeralds is between 1 and 20:
      Print: "Careful, [player_name]! You only have [remaining_emeralds] emeralds left. Spend wisely!"

    • If remaining_emeralds is less than or equal to 0:
      Print: "Oh no, [player_name]! You’re out of emeralds (or overspent). Better find some villagers to trade with!"

 

Write what you are looking for, and press enter to begin your search!