12 points 

This program reads in the ingredient list for making a spinach quiche, big enough to serve 5 people. It asks the user to enter the number of people the cook is cooking for. The program then prints out the ingredient list for the quiche, with the amount of each ingredient adjusted for the number of people the quiche should serve. The program prints both to a file and to the screen.

Here is the input file 'spinachquiche.txt':

"Spinach Quiche"
serves 5
1 9-inch "deep dish frozen pie crust"
1 tablespoon "butter"
0.5 cup "thinly sliced shallots"
4 large "eggs"
1.25 cups "heavy cream"
1 pinch "ground nutmeg"
0.75 teaspoon "salt"
0.125 teaspoon "cayenne pepper"
1 cup "finely shredded Gruyère, packed"
10 ounces "frozen chopped spinach, defrosted and wrung free of water"


Here is the output file, if the user says that they are cooking for 10 people:

Spinach Quiche

Here is the Spinach Quiche ingredient list, where the amounts have been adjusted to feed 10 people:

2.0 9-inch deep dish frozen pie crust
2.0 tablespoon butter
1.0 cup thinly sliced shallots
8.0 large eggs
2.5 cups heavy cream
2.0 pinch ground nutmeg
1.5 teaspoon salt
0.25 teaspoon cayenne pepper
2.0 cup finely shredded Gruyère, packed
20.0 ounces frozen chopped spinach, defrosted and wrung free of water


The video below shows a completed program being run.



Starting Point

Download as a starting point for the project. The file guides you towards completing the program. Also download the input file spinachquiche.txt.


Extra Credit

1 point

Two of the ingredients - pie crust and eggs - really only make sense in integer quantities. You're not going to cook a quiche with 2.5 pie crusts, and you're not going to use 4.3 eggs. So for these 2 ingredients, round 'measurement' to the nearest integer. The associated print statement will need to change. Instead of {0:0.3} use {0}.