0%

Talking with Your Program · capstone

Capstone project: Project: Make the Outing Planner Interactive

At the end of Chapter 2, you built a group outing plan from values written in the code. Now you will turn that fixed program into an interactive one.

The person running it will choose the activity, group size, price per person, and snack budget. Your program will calculate the totals and present a complete summary.

The four questions

Ask for these values in this order:

AnswerType after conversion
Activityactivitystr
Number of peoplepeopleint
Price per personprice_per_personint
Snack budgetsnack_budgetint

The activity comes directly from input(). The other three answers must be converted with int() before you calculate with them.

Use clear prompts of your own or keep the wording suggested in the starter comments. Each prompt should make it obvious what the person needs to enter.

Calculate two totals

After collecting and converting the values, create:

ticket_total = people * price_per_person
total_budget = ticket_total + snack_budget

These are the same relationships you used in the previous chapter. The difference is that the starting values now arrive while the program is running.

Print the report

Use the variables to print five lines in this form:

OUTING PLAN
Activity: planetarium
People: 4
Tickets: $52
Total budget: $70

Those example results come from these answers:

planetarium
4
13
18

Your program must also work with different suitable answers. Do not write planetarium, 4, 13, 18, 52, or 70 directly into the report or calculations.

Build in stages

Follow the IPO structure from the previous lesson.

Input

Write the four input() calls. Run the program and make sure it asks every question in order. At this stage, you can temporarily print the variables to confirm where each answer went.

Process

Convert the three numerical answers and calculate ticket_total and total_budget. Temporarily print the totals and check them with a small example.

Output

Remove temporary checks and add the five required report lines. Use for the lines containing variables.

Before you submit

Check that:

  • every input() result is assigned to a useful variable;

  • the three numerical answers are converted with int();

  • the questions appear in the required order;

  • both totals are calculated from variables;

  • the report contains exactly five non-empty lines after the prompts;

  • dollar signs appear as ordinary text outside f-string braces.

If your plan includes Guided, you can ask Monty:

Review my outing planner in Input, Process, Output order. Find the first place where a has the wrong type or meaning, and let me correct it.

After it passes

Run the project again with a real outing idea. Try a free activity by entering 0 as the price per person, or compare the total for two different group sizes.

You have now written a program whose result is decided at runtime by the person using it. That is a major step beyond fixed examples. The same input, process, output structure can power calculators, questionnaires, converters, games, and many other programs.

Task

Build an interactive outing planner that:

  1. asks for activity, people, price_per_person, and snack_budget, in that order;

  2. converts the three numerical answers with int();

  3. calculates ticket_total and total_budget;

  4. prints exactly five report lines after the questions, using for the lines containing collected or calculated values.

Calculate ticket_total from people * price_per_person, then calculate total_budget from ticket_total + snack_budget. Remove temporary debugging output before submitting.

For the test answers, the report will end with:

OUTING PLAN
Activity: planetarium
People: 4
Tickets: $52
Total budget: $70