1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
struct Menu_Items
{
string Item;
double Price;
};
struct Orders
{
string Menu_Item_Ordered;
string Day_of_Week;
string CustomerID;
int Quantity;
int Line_Item_Total;
};
const int NUM_MENU_ITEMS = 20;
const int ORDERS = 100;
const double PA_SALES_TAX = 1.06;
double GetPrice( Menu_Items [] , string );
void Biggest_Profit(double []);
int main()
{
Menu_Items Menu_List[NUM_MENU_ITEMS];
int i = 0;
ifstream InFileMenu;
InFileMenu.open("Menu.txt");
ifstream InFileOrders;
InFileOrders.open("Orders.txt");
if ( InFileMenu.fail() )
{
cout << "The 'Menu.txt' file you have entered cannot be found!!!" << endl;
system("pause");
}
else
{
cout << "The 'Menu.txt' file you have enetered was found!!" << endl;
system("pause");
string Item;
double Price;
while (InFileMenu >> Item >> Price)
{
cout << "The Menu item: #" << i + 1 << " is the " << Item << " and it cost: $" << Price << endl;
Menu_List[i].Ptem = Item;
Menu_List[i].Price = Price;
i++;
}
}
Orders Orders_Placed[ORDERS];
int Orders_Index = 0;
if (InFileOrders.fail())
{
cout << "The 'Orders.txt' file you have entered cannot be found!!!" << endl;
system("pause");
}
else
{
cout << "The 'Orders.txt' file you have enetered was found!!" << endl << endl;
system("pause");
string Menu_Item_Ordered, Day_of_Week, Customer_ID;
int Quantity, Max = 0, Num_of_Orders, Line_Item_Total;
while ( InFileOrders >> Menu_Item_Ordered >> Quantity >> Day_of_Week >> Customer_ID )
{
cout << "Customer: " << Customer_ID << " ordered " << Quantity << " " << Menu_Item_Ordered << " on " << Day_of_Week << "." << endl << endl;
Orders_Placed[Orders_Index].Menu_Item_Ordered = Menu_Item_Ordered;
Orders_Placed[Orders_Index].Quantity = Quantity;
Orders_Placed[Orders_Index].Day_of_Week = Day_of_Week;
Orders_Placed[Orders_Index].CustomerID = Customer_ID;
Orders_Index++;
if (Orders_Index > Max)
{
Max = Orders_Index;
Num_of_Orders = Orders_Index;
}
}
cout << "There was a total of " << Num_of_Orders << " orders!!!" << endl;
system("pause");
for (i = 0; i < Num_of_Orders; ++i)
{
Line_Item_Total = Orders_Placed[i].Quantity * GetPrice(Menu_List, Orders_Placed[i]) * PA_SALES_TAX;
Orders_Placed[i].Line_Item_Total = Line_Item_Total;
cout << "The line item total for " << Orders_Placed[i].Quantity << " " << Orders_Placed[i].Menu_Item_Ordered << " is: $" << setw(2) << fixed << setprecision(2) << Orders_Placed[i].Line_Item_Total << endl;
}
}
return 0;
}
double GetPrice( Menu_Items Menu[], string Item)
{
int i = 0;
for (i = 0; i < NUM_MENU_ITEMS; ++i)
if (Menu[i].Item = = Item)
return Menu[i].Price;
}
//void Biggest_Profit(double Orders_Total[])
void Biggest_Profit(double Orders_Total[])
{
double MonTotals, TueTotals, WedTotals, ThuTotals, FriTotals, SatTotals, SunTotals;
int i;
double Winner;
for (i = 0; i < ORDERS; ++i)
{
if (MonTotals < TueTotals)
Winner = TueTotals;
else if (WedTotals > Winner)
Winner = WedTotals;
else if (ThuTotals > Winner)
Winner = ThuTotals;
else if (FriTotals > Winner)
Winner = FriTotals;
else if (SatTotals > Winner)
Winner = SatTotals;
else if (SunTotals > Winner)
Winner = SunTotals;
else if (MonTotals > Winner)
Winner = MonTotals;
}
return;
}
|