Question
*USE ARRAYS AND FUNCTIONS ONLY!* The Straight Talk Bar and grill has commissioned you to write a program to keep track of its daily sales.
*USE ARRAYS AND FUNCTIONS ONLY!*
The Straight Talk Bar and grill has commissioned you to write a program to keep track of its daily sales. The people at the Straight Talk wish you to set up the program so that it prompts Laurie McCool, the manager, for the total sales of the day and reads in her reply. Now, the Straight Talk does not necessarily check its sales once a week. Laurie McCool will be running the program at random intervals. This means that you cant count her entering sales for exactly six days. Therefore, your program should incorporate a lop which will continue to prompt Laurie McCool for a days total sales until she enters the number 9999. This number will be Lauries Sentinel Signal that she is done entering the data. Be sure that your program DOESNT INTERPRET that number as the total sales for a day!
After reading in all data, your program should print out the following information:
- The number of the days for which data was entered.
- The grand total for all the sales entered.
- The average for all the sales entered.
- The best (maximum) sale and the day on which it occurred.
- The worst (minimum) sale and the day on which it occurred.
There are several things that your program should watch out for. FIRST OF ALL, Laurie McCool often partakes of the product she sells and her typing can be erratic. The total sales for day will always be a positive real number and if your program reads in a negative number, it should let her know that it is invalid and prompt for more data. Be sure that no negative numbers are used in your programs computation of the grand total, the average, etc also the counter for number off days should not be incremented when negative numbers are entered.
Laurie also occasionally begins to run the program and then changes her mind. In such an instance she types immediately 9999 in reply to the first prompt. Your program should handle this event without ABNOMALLY TERMINATTING. Be sure that if the first number is 9999 your program does not attempt the computations of the grand total, average, etc.
Laurie sometimes forgets how the program works , so your output should begin with a brief description of the program. Make sure that your prompts are clear. DONT FORGET to tell Laurie how to stop the program. All the results should be carefully explained. DO NOT USE SCIENTITIFIC NOTATIONLAURIE JUST CANT HANDLE IT!
BELOW IS MY PROGRAM WIHOUT FUNCTINS AND ARRAYS NOW HELP ME REWRITE IT USING ARRAYS AND FUNCTIONS
*PROGRAM WITHOUT FUNCTIONS */
#include
#include
using namespace std;
int main(
{
//Variables and constants
double dailysales, totalsalesCom, averagesales, bestsale, worstsale;
int days, totaldays, worstday, bestday;
cout << "Straight Talk Bar and Grill: Daily Sales Program" << endl;
cout << " This program requires you to input the total sales for a day multiple times."
<< " The program will then calculate the number fo days for which data was entered"
<< " along with the grand total, average, best sale, and worst sale."
<< " Please follow ALL directions. " << endl;
//Get user input
cout << "Please enter the total sales for a day (OR enter 9999 to stop): ";
cin >> dailysales;
while (dailysales < 0)
{
cout << "Illegal value. Please enter a number greater than 0." << endl;
cin >> dailysales;
}
if (dailysales == 9999)
cout << "No input will be displayed since no read data was entered. ";
else
{
//Display Headers
cout << "\tDay\t\t Sales ";
cout << "--------------------------------- ";
days = 1;
bestsale = dailysales;
worstsale = dailysales;
bestday = days;
worstday = days;
totalsalesCom = 0;
while (dailysales != 9999)
{
if (dailysales > bestsale)
{
bestsale = dailysales;
bestday = days;
}
if (dailysales < worstsale)
{
worstsale = dailysales;
worstday = days;
}
cout << "\t " << days << "\t\t$" << totalsales << endl;
totalsalesCom = totalsales + totalsalesCom;
days++;
cout << "Please enter the total sales for a day (OR enter 9999 to stop): ";
cin >> dailysales;
while (dailysales < 0)
{
cout << "Illegal value. Please enter a number greater than 0." << endl;
cin >> dailysales;
}
}
cout << fixed << showpoint << setprecision(2);
totaldays = days - 1;
averagesales = totalsalesCom / totaldays;
cout << " The number of days for which date was entered was: " << totaldays
<< " The grand total for all the sales entered was: $" << totalsalesCom << endl;
cout << " The average for all the sales entered was: $" << averagesales << endl;
cout << " The best sale entered = $" << bestsale << " on day " << bestday
<< " The worst sale entered = $" << worstsale << " on day " << worstday << endl;
}
return 0;
}
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