Project 1: Event planning

UC Irvine - Fall ‘22 - ICS 45C

Read everything before you start! Major updates will be listed here:

  • updated the format of the last message to match gradescope and examples (removed ; and added a new line);
  • updated the greeting: from ...many pizzas... to ...much food..., so it matches the examples at the end of this page and what the autograder expects;
  • added hints for rounding values up and down.

Due date

This project is due at 10PM PT on Friday of week 3 (2022-10-14). You have a 15-minute buffer for any technical issues and can use your extra days if needed.

Context

It’s week 1, and you just joined a new club – the Irvine Extra Exceptions Enthusiasts. To welcome all new members, your club is planning to host a party… and you just volunteered to help organize it!

You got the task of figuring out how many pizzas they should get, which can be kinda hard. Lucky for you, one of the friendly organizers shared an effective way of finding out how many pizzas you need. You then decided it would be a nice idea to put this logic into a program that others could use later on.

What you have to do

You will create a program to calculate how many pizzas should be ordered. Your program should have a main function that interacts with the user through standard input/output. Your program should complete the following steps.

Greeting

You will start with a greeting for the user:

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

Find out how many people

Then, you will find out how many people will show up. First, we let the user know:

First, we will find out how many people should show up.

You will ask how many people have RSVP’d (rsvp):

1. How many people have RSVP'd?

How sure they are that people will actually show up (show_up_ratio):

2. What's the ratio of people that usually show up?

And find out how many people are organizing (organizers):

3. How many people are helping organize this event?

We expect the organizers to RSVP too, which gives us a lower bound for how many people to expect. So with this information, we can calculate the expected number of people as the show_up_ratio of rsvp, rounded down, + 1. Then, we can compare it with the number of organizers, and the max of those two values should be the number of expected_guests.

You should add 1 to the expected number of people even if show_up_ratio is 1. Check our notes about variable types to see how you could round down.

For example, if there are 100 people that RSVP’d, and we expect 0.3 of them to show up, and there are 10 organizers, we would guess 31 people will attend. But if there are 100 people that RSVP’d, and we expect only 0.05 of them to show up, and there are 10 organizers, we would guess 10 people (the organizers) will attend.

Once we know how many guests are expected, we let the user know:

Got it! From this info, we expect [EXPECTED_GUESTS] people to attend.

You can assume that rsvp and organizers are non-negative integers, and show_up_ratio is a floating-point in the range [0, 1].

Check dietary restrictions

Next, we ask if there are any explicit requests about vegetarian options:

4. How many people requested vegetarian options?

You can assume that the user will input an integer in the range [0, expected_guests].

Check beverage options

Finally, we ask about the beverage options during the event:

5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)

For this option, expect the user to type a single character, w for water, s for soda, or n for none. If a different character is provided, you can default their selection to none. You should accept both lower and upper case inputs.

Quantity calculation

We have all the necessary information to calculate how many pizzas to order! To find the base quantities of pizzas, you should calculate the following:

  • For every 7 expected guests, order one large pizza;
  • For every expected guest left over, order one medium pizza.

However, you know that sometimes people get a little bloated from drinks. So if the user is ordering beverages, you should adjust the totals:

  • if the beverage of choice is water, then the final number of pizzas should be 90% of the base quantities;
  • if the beverage of choice is soda, then the final number of pizzas should be 75% of the base quantities;
  • if there are no beverages, the final number of pizzas should equal the base quantities.

You should round down if rounding is required.

For example, if you have 100 expected guests, your base quantities would be 14 large pizzas and 2 medium pizzas. Your final quantities would vary based on beverage:

  • if water, 12 large and 1 medium;
  • if soda, 10 large and 1 medium;
  • if none, 14 large and 2 medium.

Once you have these values, you can tell the user:

I think you should order [LARGE] large and [MEDIUM] medium pizzas.

Pizza types

The last step is to figure out what kind of pizza to get. You decided to split those quantities among two types: Hawaiian and vegetarian.

At least 20% of the pizzas should be vegetarian. However, if the ratio of vegetarian requests per guest is higher than that, you should use that instead.

For example, assuming 100 expected guests, if there were 5 requests for vegetarian options, you should use 20%. However, if there were 50 requests, you should use 50%.

In this step, you should round down the number of Hawaiian pizzas and round up the number of vegetarian pizzas.

For example, assuming 14 large pizzas, 2 medium pizzas, and a 20% ratio of vegetarian pizzas, your final tally should be:

  • Hawaiian:
    • Large: 11
    • Medium: 1
  • Vegetarian:
    • Large: 3
    • Medium: 1

Finally, you can provide the user with this final message:

From the options you entered, I think you should order:
    [HW_LG] large Hawaiian pizzas
    [HW_MD] medium Hawaiian pizzas
    [VG_LG] large vegetarian pizzas
    [VG_MD] medium vegetarian pizzas


Hope this helps!

Feel free to copy and paste the format, but the pizza options are indented with 4 spaces ;)

HINT: you should already know how to round values down – if you don’t, go up in the description! Since you know that, you don’t need to round things up to get to the correct answer. In the example, since we know we wanted 14 large pizzas total, and 11 are Hawaiian, you should already know exactly how many should be vegetarian. No pizzas are left behind!

Submission

Your code should be named food_calculator.cpp. If you need a starter file, you can click here. You should submit your solution on gradescope: https://www.gradescope.com/courses/443728/assignments/2301011/ You can submit it as many times as you want; just remember that gradescope might not give you instant feedback.

Your code will be checked for compilation (e.g., warnings), style, and functionality issues. Compilation and style checks will be completely open, so you know what needs to be changed. Functionality tests will be a mix of open and hidden ones. You should be able to debug your code based on the open ones. For this project, all functionality tests use standard IO (cin/cout) to communicate with your code and assume everything is inside main.

Sample runs

Lines that start with [INPUT] show what the user typed in; your program should not show those lines. You must have the correct line breaks and spacing. If there are any differences, gradescope should show you the expected output so you can compare them.

Note that these are just a few examples, your code will be tested with different values!

More guests

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

First, we will find out how many people should show up.
1. How many people have RSVP'd?
[INPUT] 100
2. What's the ratio of people that usually show up?
[INPUT] .99
3. How many people are helping organize this event?
[INPUT] 5

Got it! From this info, we expect 100 people to attend.

4. How many people requested vegetarian options?
[INPUT] 8
5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)
[INPUT] n

I think you should order 14 large and 2 medium pizzas.
From the options you entered, I think you should order:
    11 large Hawaiian pizzas
    1 medium Hawaiian pizzas
    3 large vegetarian pizzas
    1 medium vegetarian pizzas


Hope this helps!

More organizers

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

First, we will find out how many people should show up.
1. How many people have RSVP'd?
[INPUT] 100
2. What's the ratio of people that usually show up?
[INPUT] .05
3. How many people are helping organize this event?
[INPUT] 10

Got it! From this info, we expect 10 people to attend.

4. How many people requested vegetarian options?
[INPUT] 1
5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)
[INPUT] x

I think you should order 1 large and 3 medium pizzas.
From the options you entered, I think you should order:
    0 large Hawaiian pizzas
    2 medium Hawaiian pizzas
    1 large vegetarian pizzas
    1 medium vegetarian pizzas


Hope this helps!

Water

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

First, we will find out how many people should show up.
1. How many people have RSVP'd?
[INPUT] 100
2. What's the ratio of people that usually show up?
[INPUT] .7
3. How many people are helping organize this event?
[INPUT] 10

Got it! From this info, we expect 71 people to attend.

4. How many people requested vegetarian options?
[INPUT] 10
5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)
[INPUT] w

I think you should order 9 large and 0 medium pizzas.
From the options you entered, I think you should order:
    7 large Hawaiian pizzas
    0 medium Hawaiian pizzas
    2 large vegetarian pizzas
    0 medium vegetarian pizzas


Hope this helps!

Soda

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

First, we will find out how many people should show up.
1. How many people have RSVP'd?
[INPUT] 100
2. What's the ratio of people that usually show up?
[INPUT] .7
3. How many people are helping organize this event?
[INPUT] 2

Got it! From this info, we expect 71 people to attend.

4. How many people requested vegetarian options?
[INPUT] 1
5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)
[INPUT] S

I think you should order 7 large and 0 medium pizzas.
From the options you entered, I think you should order:
    5 large Hawaiian pizzas
    0 medium Hawaiian pizzas
    2 large vegetarian pizzas
    0 medium vegetarian pizzas


Hope this helps!

Extra vegetarian pizzas

----------
Hello! Welcome to the ieee food calculator.
I'll help you calculate how much food you should order for an event!
----------

First, we will find out how many people should show up.
1. How many people have RSVP'd?
[INPUT] 20
2. What's the ratio of people that usually show up?
[INPUT] 1
3. How many people are helping organize this event?
[INPUT] 9

Got it! From this info, we expect 21 people to attend.

4. How many people requested vegetarian options?
[INPUT] 20
5. What type of beverage will be available? ([W]ater, [S]oda, [N]one)
[INPUT] y

I think you should order 3 large and 0 medium pizzas.
From the options you entered, I think you should order:
    0 large Hawaiian pizzas
    0 medium Hawaiian pizzas
    3 large vegetarian pizzas
    0 medium vegetarian pizzas


Hope this helps!