The goal of this program is to create a cash register for the sale of three candies. We are suppose to use call functions to perform a sale, show how many customers there were, total revenue and how many candies were sold. We are not allowed to use any global variables besides the constants that I have declared. I am getting an error that says that every value that I am returning is not initialized, I am not understanding how to fix this error. Hopefully this all makes sense, thanks for the help!
Code:
#include <iostream>
#include <iomanip>
using namespace std;
const double mm = 3.50;
const double mandi = 4.0;
const double raisn = 2.5;
double displayCount(double cmm, double cmandi, double craisn);
double makeSale();
void displayRevenue(double rev);
void displayCustomers(double customers);
int menu()
{
int choice;
cout << "Enter 1 to make a sale" << "/n" << "Enter 2 to see number of boxes of each type of candy sold"
<< "\n" << "Enter 3 for total revenue" << "\n" << "Enter 4 to see the number of customers " <<
"\n" << "Enter 5 to close the program" << endl;
cin >> choice;
while (choice == 1 || choice == 2 || choice == 3 || choice == 4 || choice == 5)
{
if (choice == 1)
{
makeSale();
}
else if (choice == 2)
{
double cmm, cmandi, craisn;
displayCount(cmm, cmandi, craisn);
}
else if (choice == 3)
{
displayRevenue(choice);
}
else if (choice == 4)
{
double customers;
displayCustomers(customers);
}
else if (choice == 5)
{
break;
}
else
{
cout << "please read the options again and choose one on the list" << endl;
}
}
cout << "please try again" << endl;
return choice;
}
double makeSale()
{
int a;
double cmm = 0, cmandi = 0, craisn = 0, customers = 0;
cout << "Enter 1 for Mike and Ike" << endl << "Enter 2 for Rasiennettes" << endl << "Enter 3 for M & M's " << endl;
cin >> a;
double y,rev;
if (a == 1)
{
cout << "What is the quantity? " << endl;
cin >> y;
double rev = rev + (y * mandi);
cmandi = cmandi + y;
customers++;
}
else if (a == 2)
{
cout << "What is the quantity? " << endl;
cin >> y;
double rev = rev + (y * raisn);
craisn = craisn + y;
customers++;
}
else if (a == 3)
{
cout << "What is the quantity? " << endl;
cin >> y;
double rev = rev + (y * mm);
cmm = cmm + y;
customers++;
}
else
{
cout << "please try again" << endl;
}
return rev;
return cmm;
return cmandi;
return craisn;
return customers;
}
double displayCount(double & cmm, double & cmandi, double & craisn)
{
cout << "You sold " << cmm << " M&Ms and " << cmandi << " Mike and Ikes and " << craisn << " Raisennettes" << endl;
return 0;
}
void displayRevenue(double & rev)
{
cout << "The total revenue for the day is " << rev << endl;
}
void displayCustomers(double customers)
{
cout << " The number of customers is: " << customers << endl;
}