More dwarves?

Tags
Challenge
No

You have some Snow Whites and some dwarves. Each Snow White needs seven dwarves, but you might have more or fewer dwarves than you need. Write a program to figure out how many dwarves to add, or get rid of.

Ask the user for the number of Snow Whites they have, and the number of dwarves. Both must be integers. There must be 1 or more Snow Whites, but not more than 17. There must be 0 or more dwarves, but not more than 93.

Compute the number of dwarfs needed or are extra. Use the output format below.

Here's some I/O.

  • How many snow whites? 2
  • How many dwarfs? 14
  •  
  • Central Casting
  • ======= =======
  •  
  • Dwarf hiring order
  •  
  • You have the right number of dwarfs.

More I/O. Note that singular/plural is handled correctly.

  • How many snow whites? 1
  • How many dwarfs? 6
  •  
  • Central Casting
  • ======= =======
  •  
  • Dwarf hiring order
  •  
  • Hire one more dwarf.

More I/O:

  • How many snow whites? 2
  • How many dwarfs? 16
  •  
  • Central Casting
  • ======= =======
  •  
  • Dwarf hiring order
  •  
  • Get rid of 2 dwarfs.

More I/O:

  • How many snow whites? some
  • Sorry, you must enter a whole number.
  • How many snow whites? 99
  • Sorry, please enter a number one or more, and 17 or less.
  • How many snow whites? 0
  • Sorry, please enter a number one or more, and 17 or less.
  • How many snow whites? 2
  • How many dwarfs? 999
  • Sorry, please enter a number zero or more, and 93 or less.
  • How many dwarfs? a lot
  • Sorry, you must enter a whole number.
  • How many dwarfs? 13.5
  • Sorry, you must enter a whole number.
  • How many dwarfs? 13
  •  
  • Central Casting
  • ======= =======
  •  
  • Dwarf hiring order
  •  
  • Hire one more dwarf.

Hints (you don't need to use them all):

  • The abs() function will take the absolute value of a number. So abs(3) and abs(-3) are both 3.
  • The str() function will convert an int or float into a string.
  • The number of dwarves needed is seven times the number of Snow Whites, minus the number of dwarves you have. If you have too many dwarves, that value will be negative.

If you have the right number of dwarves, the message might be "You have the right number of dwarves."

If you have one too many dwarves, the message might be "Get rid of one dwarf."

If you have way too many dwarves, the message might be "Get rid of [number] dwarves."

Upload a zip of your project folder. The usual coding standards apply.

Where referenced