Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A food bank tries to package boxes of non - perishable items. Each box should contain exactly 6 items, including two peach cans, two bean

A food bank tries to package boxes of non-perishable items. Each box should contain exactly 6 items, including two peach cans, two bean cans, one cereal, and one fish can. You are tasked to write a program to check whether the items within a box are correct or not.
For simplicity, the items are represented as individual single capital letters. That is,'P' for a peach can, 'B' for a bean can, 'C' for a box of cereal, and 'F' for a fish can. Your program will take a sequence of these capital letters that end with '-'(indicating closing the box) as input. These letters are separated by whitespace. Then, it will check whether the sequence contains exactly 6 letters or not. If not, the program will output the following and exit.
Incorrect total number of items
Otherwise, the program will check the numbers of peach cans, bean cans, cereal, and fish cans, respectively. If either of these numbers is not equal to the expected number (see above), the program will output the following and exit.
Incorrect items:
If all numbers are correct, the program will output the following and exit
Correct

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

3. What information do participants need?

Answered: 1 week ago