Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- //Structure of the Menu Item
- struct menuItem{
- char description[25];
- float price;
- int count;
- };
- //For display float values upto 2 decimal
- float round(float var)
- {
- float value = (int)(var * 100 + .5);
- return (float)value / 100;
- }
- //For display Menu Item List
- void displayMenu(menuItem menu[]){
- int i;
- for(i=0; i<6; i++)
- cout << "\n["<< i+1 <<"] "<< menu[i].description <<"\t $" << round(menu[i].price) ;
- }
- //For Getting highest Menu Item List index
- void mostorder(menuItem menu[]){
- int i, countIndex = 0;
- for(i=1; i < 6; i++){
- if(menu[i].count > menu[countIndex].count)
- countIndex = i;
- }
- cout << "\nItem ordered most often: " << menu[countIndex].description
- <<" was purchased " << menu[countIndex].count << " times\n";
- }
- //For Order Menu's Item
- float orderItems(menuItem menu[]){
- int i = 0, j, order[10], flag = 0;
- float subTotal = 0;
- //Takes order list
- cout<<"\nInput the item numbers for the order, 0 to quit\n";
- do{
- cin >> order[i++];
- }while(order[i-1] != 0);
- //checks whether extra item added
- for(j=0; j < i-1; j++){
- // cout << order[j] << "\t";
- if(order[j] < 1 || order[j] > 6){
- cout <<"\n*Error: There is no item."<< order[j];
- flag = 1 ;
- }
- }
- if(flag == 1){
- cout<< "\nProcessing other items...";
- }
- //For calculating subtotal
- for(j = 0; j < i-1; j++){
- if(order[j] >= 1 || order[j] <= 6){
- subTotal += menu[ (order[j]) - 1].price ;
- menu[(order[j]) - 1].count++;
- }
- }
- return subTotal;
- }
- int main(){
- int i, j, order[10], countIndex;
- float subTotal = 0, Tax = 0, Total, TotalSales;
- char decision ;
- menuItem menu[6] = { { "MacBook Air", 1099.00, 0 },
- { "MacBook Pro", 1299.00, 0 },
- { "iPad Air", 499.00, 0 },
- { "IPad Pro 11-in", 799.00, 0 },
- { "Pad Pro 12.9-in", 999.00, 0 },
- { "Watch S4", 399.00, 0 }};
- do{
- displayMenu(menu);
- subTotal = orderItems(menu);
- Tax = subTotal * 0.0825;
- cout << "\nSubtotal...$ " << round(subTotal);
- cout << "\nTax........$ " << round(Tax);
- Total = subTotal + Tax ;
- cout << "\nTotal......$ " << round(Total);
- cout << "\n\nPlease enter 'N' to take a new order and 'E' to exit: " ;
- cin >> decision ;
- TotalSales += Total;
- }while(decision != 'E');
- cout << "\n*** End of Day:";
- cout << "\nTotal sales: $ " << round(TotalSales) ;
- mostorder(menu);
- return 1;
- }
- https://media.cheggcdn.com/media/2d1/2d150fb6-3bfd-4398-b775-b79fa53c6edc/phpV70m3N.png
- https://media.cheggcdn.com/media/490/49026e75-d901-49c1-bfae-1371fec0eeb9/phpjjOBkn.png
- https://media.cheggcdn.com/media/6fe/6fe106f7-f574-4475-b5e0-fbf157af81a6/phpi9oQnX.png
- https://media.cheggcdn.com/media/83a/83ae0825-e174-4979-8b30-9a04fd46fc52/phpNBr8fX.png
- https://media.cheggcdn.com/media/c9a/c9a843ce-c124-4b5b-9c4d-9f0bf05d6662/phpHQ0gny.png
Advertisement
Add Comment
Please, Sign In to add comment