1. Write
a class SHOP that sells teddy bears. The shop stores the number
and price of a teddy bear. The user inputs a number, you check if you have
enough, and reply "OK" or "Nope". If you have enough bears, then sell that
number to the happy shopper (decrement the number of bears and increment
the money). Develop the code in four steps:
a)
Code the class template and feature headers.
b)
Code a routine to process a single user
input.
c)
Wrap a loop around the test, and exit the
loop when all the bears have been sold.
d)
Add the ability to exit the loop at any
time. Show the number of bears left at that time.
2. Write a routine factorial to calculate n! (n factorial) using a loop.
3. Write code to produce the following pattern; use routines for modularity:
*
***
*****
***
*
4. Adapt your code to produce the following pattern:
*
+++
-
- - - -
^^^
!
a, A "eh?"
d, D ask for a number,
double it, and display the result
e, E exit the menu