Exercises
Assume that you are the mananger of a restaurant.
Incorporate appropriate preprocessor directives (#include <iostream)
Incorporate appropriate function prototypes (see requirements below)
Establish a price for cokes, fries, and burgers and set a tax rate and make them global variables. No other variables can be global
Note: a global variable is a variable defined outside any function - place them above the main
In the main program
Call a function to greet the customer (assume only 1 customer - do not use a loop)
Call a function to state prices
Call a function to take number of cokes
Call a function to take number of fries
Call a function to take number of burgers
Call a function to calculate the total price
Call a function to announce the price
Call any necessary functions not mentioned above
Write additional functions after the main to accomplish the above.
Ask the customer how much money he is providing in payment in terms of dollars, quarters, dimes, nickles, and pennies.
Calculate and tell the customer what the change is in terms of the above, as appropriate.
Part a
(1) Define the following. Include an example in your definition.
(a) Function Scope
(b) File Scope
(c) Block Scope
(d) Function-Prototype Scope
Part b
Chapter 6 of the text, Exercises, Exercise 6.12, pages 316-317.
An integer is said to be perfect if the sum of its factors, including 1 (but not the number itself) is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3.
Write a function named perfect that detetrmines whether the parameter passed to it, number, is a perfect number.
Use this function in a program that finds all the perfect numbers between 2 and 10,000. Print the first 5, one per line, along with the factors.