hy can anyone help me out with this code plz
#include <iostream> //Declarations
#include <iomanip>
#include <fstream>
#include <cstdlib>
using namespace std;
double SaleSlcdDep();
double SaleALLDep();
double AveSaleALLDep();
double HighestSaleALLDep();
double alphatest1();
double alphatest2();
double menu();
int main()
{
double sales[12]; // Sales Input for the 12 departments
double result;
int ii;
ofstream outfile ("system.dat");
for(ii=0;ii<12;ii++)
{
cout << "Enter Sales For Department " << ii+1 << '\n';
cin >> sales[ii];
alphatest2();
while (!(sales<=0||sales>=0))
{
cout << "Error,Please ReEnter";
cin >> sales[ii];
}
outfile << sales[ii] << '\n';
}
outfile.close();
system ("cls");
result=menu();
return 0;
}
double menu() //Input's Systems menu
{
int result;
double valA;double valB;
double valC;double valD;
cout << "+=============+\n";
cout << "| System Menu |\n";
cout << "+=============+\n\n";
cout << "+=========================================================+\n";
cout << "| |\n";
cout << "| 1. Display sales for a specified Department. |\n";
cout << "| 2. Display sales for all Departments. |\n";
cout << "| 3. Display average sales for all the Departments. |\n";
cout << "| 4. Display highest sales for all Departments. |\n";
cout << "| 5. Exit. |\n";
cout << "| |\n";
cout << "+=========================================================+\n";
cin >> result;
system ("cls");
switch (result)
{ case 1:
{valA=SaleSlcdDep();
return 0;}
case 2:
{valB=SaleALLDep();
return 0;}
case 3:
{valC=AveSaleALLDep();
return 0;}
case 4:
{valD=HighestSaleALLDep();
return 0;}
case 5:
return 0;
}
return 0;
}
double SaleSlcdDep() //Sales Input for the Specific Departments
{
int deptNo;
int selection;
int i;
double sales[12];
double valA;
cout << "Please enter the Department Number :" << '\n';
cout << "Department #1." << '\n';cout << "Department #2." << '\n';
cout << "Department #3." << '\n';cout << "Department #4." << '\n';
cout << "Department #5." << '\n';cout << "Department #6." << '\n';
cout << "Department #7." << '\n';cout << "Department #8." << '\n';
cout << "Department #9." << '\n';cout << "Department #10." << '\n';
cout << "Department #11." << '\n';cout << "Department #12." << '\n';
cin >> deptNo;
alphatest1();
deptNo=deptNo--;
ifstream infile ("system.dat");
for(i=0;i<11;i++)
infile >> sales[i];
cout << "Sales for Department " << deptNo++<< " = " << "$" << sales[deptNo] << '\n';
infile.close();
cout << "\n1. +----------------------+";
cout << "\n |Return to system menu |";
cout << "\n +----------------------+";
cout << "\n5. Exit\n";
cin >> selection;
system ("cls");
switch (selection)
{
case 1:
valA=menu();
case 2:
return 0;
}
return 0;
}
double SaleALLDep() //Veiw all of the Sales
{
int selection;
int i;
double sales[12];
double valA;
system ("cls");
ifstream infile ("system.dat");
cout << "Department sales: " << '\n';
for(i=0;i<12;i++)
{
infile >> sales[i];
cout << i+1 << "=" << "$" << sales[i] << '\n';
}
infile.close();
cout << "\n1.+---------------------+";
cout << "\n |Return to system menu|";
cout << "\n +---------------------+";
cout << "\n5. Exit\n";
cin >> selection;
system ("cls");
switch (selection)
{
case 1:
valA=menu();
case 2:
return 0;
}
return 0;
}
double AveSaleALLDep() //Average of all the sales
{
int selection;
int i;
double valA;
double sum;
double sales[12];
sum = 0;
system ("cls");
ifstream infile ("system.dat");
for(i=0;i<12;i++)
{
infile >> sales[i];
sum+=sales[i];
}
cout << "Average sales for all Departments = " << sum/12;
infile.close();
cout << "\n1.+---------------------+";
cout << "\n |Return to system menu|";
cout << "\n +---------------------+";
cout << "\n5. Exit\n";
system ("cls");
switch (selection)
{
case 1:
valA=menu();
case 2:
return 0;
}
return 0;
}
double HighestSaleALLDep() //Highest sale recorded
{
int selection;
int i;
int highdept;
double sales[12];
double valA;
double high=0;
system ("cls");
ifstream infile ("system.dat");
for(i=0;i<12;i++)
{
infile >> sales[i];
if(sales[i]>high)
{
high=sales[i];
highdept=i;
}
}
cout << "Highest sales = " << high << " for department " << highdept+1;
infile.close();
cout << "\n1.+---------------------+";
cout << "\n |Return to system menu|";
cout << "\n +---------------------+";
cout << "\n5. Exit\n";
cin >> selection;
system ("cls");
switch (selection)
{
case 1:
valA=menu();
case 2:
return 0;
}
return 0;
}
double alphatest1() //Valadidity test for function one input
{
int selection;
double valA;
system ("cls");
ifstream infile ("system.dat");
while(!cin.good())
{
cout << "Error in Input";
cin.clear();
cin.ignore(20,'\n');
cout << "\n1. Return to previous file";
cout << "\n2. Return to system menu";
cout << "\n3. Exit\n";
cin >> selection;
system ("cls");
switch (selection)
{
case 1:
valA=SaleSlcdDep();
case 2:
valA=menu();
case 3:
return 0;
}
system ("cls");
menu();
}
return 0;
}
double alphatest2() //Valadidity test for initial sales input
{
int selection;
system ("cls");
ifstream infile ("system.dat");
while(!cin.good())
{
cout << "Error in Input";
system ("cls");
return 0;
}
return 0;
}
its soo bugged i donno how it even works lol
if anyone could help me out "//Average of all the sales" is not working fine and any other ones u notice
much appreciation
thanks