Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add to your menu logic the use of a static variable to keep count of how many ti

ID: 3736925 • Letter: A

Question

Add to your menu logic the use of a static variable to keep count of how many times that the program's main menu has been invoked. For example, after we have added 2 turbo prop flights, and 1 heavy jet flight, the number of this static variable should be 4 (this is the 4h time we have invoked the menu), and your program will display "Number of hits today is 4" on the display (again, where is your design choice). You will create a separate function just for this task. See the sample display of what your program should be doing

Explanation / Answer

Here you go champ!!

#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

int countMe() {
   static int i = 0;
   i++;
   return i;
}


void menu()
{
   int count = countMe();
   cout << " _____________________________ ";
   cout << "|" << "Number of hits today is " << count << setw(4) << "|" << endl;  
   cout << " _____________________________ ";
   cout << endl;
   cout << " ______________________________________________________________ ";
   cout << "|--------------------------------------------------------------| ";
   cout << "|" << setw(45) << "Tanner Dobson's Airlines" << setw(18) << "|" << endl;
   cout << "|" << setw(40) << "Activity System" << setw(23) << "|" << endl;
   cout << "|______________________________________________________________| ";
   cout << "|" << setw(40) << "MAIN MENU" << setw(23) << "|" << endl;
   cout << "|" << setw(40) << "1) Helicopter" << setw(23) << "|" << endl;
   cout << "|" << setw(40) << "2) Turbo Prop" << setw(23) << "|" << endl;
   cout << "|" << setw(41) << "3) Midisize Jet" << setw(22) << "|" << endl;
   cout << "|" << setw(39) << "4) Heavy Jet" << setw(24) << "|" << endl;
   cout << "|" << setw(34) << "5) Quit" << setw(29) << "|" << endl;
   cout << "|" << setw(63) << "|" << endl;
   cout << "|______________________________________________________________| ";
   cout << endl;
   cout << setw(57) << "Flight ID: " << endl;
   cout << setw(57) << "Number of hits today: " << endl << endl;
}

int main() {
   for (int i = 0; i < 5; i++)
       menu();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote