Need assistance with Menu Driven Programming Assessment!

This is a discussion on Need assistance with Menu Driven Programming Assessment! within the C++ Programming forums, part of the General Programming Boards category; I am writing a program which takes in marks and manipulates the marks according to the menu selection. I am ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    Exclamation Need assistance with Menu Driven Programming Assessment!

    I am writing a program which takes in marks and manipulates the marks according to the menu selection.
    I am new to programming and need a push in the right direction! My current issue isn't much that my program may be incorrect (syntax wise) its that nothing is being displayed for CASES 1.
    THANK YOU!

    Code:
    #include <iostream>
    #include <string>
    #include <iomanip>
    #include <cstring>
    using namespace std;
    
    
    int AddStudM (int Studm[], int MaxM=1000);
    // prototypes above.
    
    int main ()
    {
        int loop=1;
        int choice;
        
        
        while (loop==1)
        {
              system ("CLS");                  //Question 3
              cout << " ** MENU **\n\n"
                   << "0. Exit \n"
                   << "1. Add Student mark \n"
                   << "2. List all student marks \n"
                   << "3. Calculate the marks average \n"
                   << "4. Calculate the standard deviation \n"
                   << "5. Delete a student mark \n"
                   << "6. find the number of students via mark \n"
                   << "7. Display distinct marks and their occurrences \n";
              cout << "\n\nSelect from the menu above: ";     
              cin >> choice;
              switch(choice)
              {
                   case 0:
                        cout << "Good bye\n\n";
                        system ("pause");
                        exit(0);
                   case 1:
                        system ("CLS");
                        int AddStudM (int Studm[], int MaxM);
                        system ("pause");
                        system ("CLS");
                        main();
                        break;
        
                   case 2:
                        system("CLS");
                        cout << "\t-- List all student marks --\n\n";
                        system ("pause");
                        system("CLS");
                        break;
                        
                   case 3:
                        system("CLS");
                        cout << "\t-- Calculate the marks average --\n\n";
                        system ("pause");
                        system("CLS");
                        break;
                        
                   case 4:
                        system("CLS");
                        cout << "\t-- Calculate the standard deviation --\n\n";
                        system ("pause");
                        break;
                        
                   case 5:
                        system("CLS");
                        cout << "\t-- Delete a student's mark --\n\n";
                        system ("pause");
                        system("CLS");
                        break;
                        
                   case 6:
                        system("CLS");
                        cout << "\t-- Find the number of students via a mark --\n\n";
                        system ("pause");
                        system("CLS");
                        break;
                        
                   case 7:
                        system("CLS");
                        cout << "\t-- Display distinct marks and thei occurrences --\n\n";
                        system ("pause");
                        system("CLS");
                        break;
                        
              }
              }
              
        }
        
    //  1. Add a student mark!    
        
    int AddStudM (int Studm[], int MaxM)
    
    
                int Mark;
                int i;
                for (i=0; i< MaxM; i++)
                {
                    cout << "enter mark for student: ";
                    cin >> Mark;
                    Studm[i]=Mark;
                } 
        i++;
        return 0;
        }
    }

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    2
    If it has any value to your attempt in compiling this code, I am using Dev C++ 4.9.9.2

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    Well first you need to declare an array of students at the beginning of main.

    Then you need to pass that array to the function in a function call (all you have is another prototype).

    Finally, NEVER call main() recursively. The code will loop quite happily as written.
    Eg.
    Code:
                   case 1:
                        system ("CLS");
                        AddStudM (Studm, MaxM);
                        system ("pause");
                        system ("CLS");
    // NEVER                    main();
                        break;
    At some point, you should remove all your system("foo") calls as well. There's usually a much better way to achieve the same thing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu driven program
    By paushali in forum C Programming
    Replies: 10
    Last Post: 11-26-2007, 09:52 AM
  2. Menu-Driven Program Help...
    By eun-jin in forum C++ Programming
    Replies: 3
    Last Post: 05-29-2006, 02:58 PM
  3. Menu driven code
    By liquidcourage1 in forum C++ Programming
    Replies: 13
    Last Post: 04-23-2006, 05:51 PM
  4. C menu driven program
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 04-25-2002, 08:56 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21