Question
The wine cellar (C program, please it has to run like example. I been trying but just can,t get it right). An eccentric wine lover
The wine cellar (C program, please it has to run like example. I been trying but just can,t get it right).
An eccentric wine lover buys individual labels of wine in either 1, 3, 6, or 12 bottle lots and consumes either 1 or 2 bottles of the same type at a time.
Unfortunately, his wine cellar can only hold 50 bottles and he is further constrained by the fact that he wishes it keep wines of a particular label in contiguous areas of his cellar so that he can easily tell how many bottles of a particular type he has left. Once positioned in the cellar, a bottle is never moved to another position.
Write and test a C program that shows how his wine stock varies as he buys and consumes wine.
Input: lines of the form
N, C N is 1, 3, 6, or 12 representing purchases or 1 or 2 representing consumption
C is an identifying character for the wine type
N = 0 terminates the program
Output
After each input line your program outputs either an error message or a depiction of the cellar
Example program run. It has to run exactly like this.
Enter number,type :7,a
invalid buy quantity: 7
Enter number,type :3,a
aaa
Enter number,type :6,b
aaabbbbbb
Enter number,type :-3,b
invalid consume quantity: -3
Enter number,type :-2,b
aaa bbbb
Enter number,type :6,c
aaa bbbbcccccc
Enter number,type :-1,c
aaa bbbb ccccc
Enter number,type :-2,d
consume failed
Enter number,type :6,b
buy failed
Enter number,type :3,b
aaabbbbbbbccccc
Enter number,type :12,d
aaabbbbbbbcccccdddddddddddd
Enter number,type :12,e
aaabbbbbbbcccccddddddddddddeeeeeeeeeeee
Enter number,type :12,f
buy failed
Enter number,type :-2,d
aaabbbbbbbccccc ddddddddddeeeeeeeeeeee
Enter number,type :-2,e
aaabbbbbbbccccc dddddddddd eeeeeeeeee
Enter number,type :3,f
aaabbbbbbbccccc dddddddddd eeeeeeeeeefff
Enter number,type :3,d
aaabbbbbbbcccccddddddddddddd eeeeeeeeeefff
Enter number,type :1,d
aaabbbbbbbcccccddddddddddddddeeeeeeeeeefff
Enter number,type :1,e
buy failed
Enter number,type :1,f
aaabbbbbbbccccdddddddddddddddeeeeeeeeeeffff
Enter number,type :0,x
Bye
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