Answered step by step
Verified Expert Solution
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 nonperishable items. Each box should contain exactly 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 isP 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 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started