Advertisement
hfxdesign

Void Menu Function

Nov 5th, 2014
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. void menu(){
  2.     const int colWidth[2] = { 10, 5 };
  3.     struct {
  4.         char* itemName;
  5.         float itemPrice;
  6.     }food[7] = {
  7.         "Hamburger",    6.0,
  8.         "Hotdog",       4.5,
  9.         "Peanuts",      3.75,
  10.         "Popcorn",      5.5,
  11.         "Soda",         2.8,
  12.         "Chips",        1.0,
  13.         "Water",        2.0
  14.     }, *p_food = &food[0];
  15.  
  16.     std::cout << "Baseball Game Snacks" << std::endl;
  17.     for (int i = 0; i < (sizeof(food) / sizeof(food[0])); *p_food++)
  18.         std::cout
  19.         << std::fixed << std::setprecision(2) << std::right
  20.         << ++i << ")"
  21.         << std::setw(colWidth[0]) << (*p_food).itemName << ":"
  22.         << std::setw(colWidth[1]) << "$" << (*p_food).itemPrice << "\n";
  23.  
  24.         std::cout << "\n8) END ORDER" << std::endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement