Menu, how to put calculation in there

Discussion in 'C++' started by khelly, Dec 27, 2011.

  1. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    so, this is my coding.

    Code:
    #include<iostream.h>
    #include<fstream.h>
    #include<stdlib.h>
    #include<iomanip.h>
        using std::cout;
        using std::cin;
        using std::endl;
        
        struct menu
        typedef struct menu RECORD;
        void addRecord(RECORD input[], int arraycounter);
        void printRecord( input[]);    
        void printAllRecord( input[]);
        
    int main()
    {
        fstream submit;
        submit.open("D:jualan.dat",ios::out);
        
        {
        int menuEnter;
        int arraycounter=0;
        
        do
        {
        cout<<"\tFamily Outfit Shop"<<endl;
        cout<<"\t    MAIN MENU"<<endl;
        cout<<"\t-------------------"<<endl;
        cout<<" 1 = Add a record\n";
        cout<<" 2 = Displays sales report for a category\n";
        cout<<" 3 = Displays sales report for all category\n";
        cout<<" 4 = Exit";
        cout<<"\nEnter Menu Number : ";
        cin>> menuEnter;
         
        if(menuEnter == 1 )
        addRecord;
        else if (menuEnter == 2 )
        printRecord;
        else if (menuEnter == 3)
        printAllRecord;
        } while (menuEnter!=4);
        return 0;
        }
         
        void addRecord(RECORD input[], int arraycounter);
        {
        char codeCate; // code category
        char codeNumbCate;  // code number category
    
        cout<<"Enter code category : \n";
        cin>>input[arraycounter].codeCate;
        cout<<"Enter code number of category : \n";
        cin>>input[arraycounter].codeNumbCate;
        arraycounter++;
        }
         
        void printRecord(RECORD input[]);
        {
         
        cout<<"SALES REPORT FOR "<<explanation<<endl;
        cout<<"\nItem Number\t\tPrice" << endl;
        cout<<"------------------------------"<<endl;
        cout<<codeCate<<"\t\t"<<price<<endl;
        cout<<"------------------------------"<<endl;
        cout<<"Total Sales\t\t"<<totalSales<<endl;
        cout<<endl;
        }
    
        void printAllRecord(RECORD input[]);
        {
        cout<<"SALES REPORT FOR ALL CATEGORIES"<<endl;
        cout<<"\nCategory\t\tSales" << endl;
        cout<<"------------------------------"<<endl;
        cout<<explation<<"\t\t"<<price<<endl;
        cout<<"------------------------------"<<endl;
        cout<<"Total Sales\t\t"<<totalSales<<endl;
        cout<<endl;
        }
    }
    error? yes, it is, bcoz i still did not finish it...
    still, i'm running doing this coding and keep doing it, but i need help.
    i keep doing mine, still someone must help me.
    i will post update for my new coding...

    there is the question. sorry bcoz it is long.
    so, how / where to put claculation in there?
    i means, in record or print...
    i try....
    and also, how to display multiple of item number?
     
  2. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    A101= a =10.00
    b101= b = 12.00
    a102 =a= 5.00
    b105= b = 17.00
    c103 =c= 40.00
    d101 =d = 15.00
    b104 =b =20.00
     
  3. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    seriously anybody?
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Your "struct menu" statement is incomplete. The compiler won't be able to get past that until you complete the statement.

    Let me tell you how professionals write code. They write a FEW lines at a time - 4-5 is not unknown - then compile it and look for errors, fix them, then run the code and make sure it works. Then they write a few more lines - again maybe 4-5, maybe more, maybe less, then compile and run. It looks like you're trying to write the whole program before compiling it.

    Get the code you have written so far working, THEN we'll look at how to add calculations. Post your reply here; do not keep creating new threads.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice