CMPS 1043 – Program 6 Arrays - Ed’s Hot &... Ed’s Hot & Spicy Salsa wants a program to keep...

advertisement
CMPS 1043 – Program 6 Arrays - Ed’s Hot & Spicy Salsa
Ed’s Hot & Spicy Salsa wants a program to keep track of his sales. Ed produces 5 different
types of salsa: Ed’s Sissy Salsa, Ed’s Sweet Salsa, Ed’s Summer Salsa, Ed’s Hot & Spicy Salsa,
and Ed’s “Make You Cry” Salsa. He also produces packages of Ed’s Chili Chips. He goes to a
variety of arts and crafts shows selling his chips & salsas around the holidays. He wants a
program that will tally his sales after each arts & crafts show.
You will utilize 4 parallel arrays for the salsa products, each containing 7 elements. They will be
defined as follows:
string Name [7];
float Cost [7];
int NumSold [7];
float Total [7];
The Name array will be initialized with the full salsa & chip names as given above. (The last
element in the array will remain blank.) The Cost array will be initialized with the cost per jar:
3.00, 3.50, 4.00, 3.50, 3.95, 4.25. The values in these 2 arrays will not change during the
execution of the program.
In main, ask the user for the number of jars of each type of salsa, printing the complete name.
Store the results in NumSold. E.G. How many jars of Ed’s Sissy Salsa did you sell?
Main will then call the function CaclulateTotal to compute the values for the array Total. It will
then call SumArray twice, for the NumSold array and for the Total array. (SumArray is to be
an overloaded function as discussed in class.) Main will then print a table of results to a file as
shown below. Names are to be left justified and numbers must be right justified. Money is to
be printed with $ and 2 decimal points. Print totals for only NumSold & Total.
Write a function called CalculateTotal which accepts as parameters the 3 arrays NumSold,
Cost, and Total. The function will compute and fill the Total array by multiplying the
corresponding elements in the NumSold array by the Cost array and storing in the Total array.
Write a function called SumArray which accepts as a parameter a single numeric arrays. It
sums the first 6 elements and stores the result in the 7th (last) location of the array.
Ed’s Hot & Spicy Salsa - Holiday Sales (Programmer: your name)
Product
Ed’s Sissy Salsa
Ed’s Sweet Salsa
Etc….
Ed’s Chili Chips
Sales Totals
Cost per Item
$ 3.00
$ 3.50
Number Sold
25
50
$
$
Total
75.00
$ 4.24
.
.
XX
$ XXXXXXX
Use your own number sold data for testing. Data to be used for turning in will be posted to the
web site.
Download