Thread: Menu, how to put calculation in there

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Menu, how to put calculation in there

    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.

    Family Outfit Shop decided to create a computerized system to maintain the shop inventory. The shop sells variety of garments and the garments are categorized to a particular group. Each category is given a code and the explanation for each code is given bellow.


    CODE | EXPLANATION
    A | baby wear
    B | children wear
    C | ladies wear
    D | menswear

    You as a programmer are required to write a program which contains a menu as bellow:

    Family Outfit Shop
    MAIN MENU
    1)Add a record
    2)Display sales report for a category
    3)Display sales report for all category
    4)Exit


    Guideline
    The program should give the user an option to choose any sub menu and it would only stop when the user choose the Exit sub menu.

    1)Add a record
    This sub menu will add a sales record for a particular garment into a file name jualan.dat. Each record consists of three fields which are item number, item code and price. The user may add more than one record at a time. You can use a sentinel value to control the loop. Assumed that file jualan.dat already exists. Example of file jualan.dat is shown as bellow:
    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


    2)Display sales report for a category
    In this sub menu the sales report of a particular category will be displayed. The category shall be chosen by the user.

    SALES REPORT FOR BABY WEAR
    Item Number | Price
    A101 | 10.00
    A102 | 5.00
    Total Sales | 15.00


    3)Display sales report for all category
    In this sub menu the sales report for all the categories will be displayed.

    SALES REPORT FOR ALL CATEGORIES
    Category Sales
    Baby wear 15.00
    Children wear 49.00
    Ladies wear 40.00
    Menswear 15.00
    Total Sales 119.00


    4)Exit
    End of program.
    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?
    Last edited by khelly; 12-26-2011 at 11:13 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What are lines 37,39,41 missing, to make them into function calls?
    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.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    seriously anybody?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The problem is due to your crosspost. People around here don't like that. Who knows how many other places you've asked the same question?
    Stick to one forum and then spread out if no one can answer your question.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    That and the post is really not much more than "finish my homework for me".

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > void addRecord(RECORD input[], int arraycounter);
    Remove the ; at the end of this line (and the same for all your other function definitions).

    Then move all your function definitions outside main - C and C++ don't support nested functions.
    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.

  8. #8
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    Quote Originally Posted by rags_to_riches View Post
    plz dont do this bcoz im studying, i not counting only one place to..

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    People dislike crossposting, so suck it up, admit it you were wrong and stick to one forum.
    Studying is not a valid excuse.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help With Calculation
    By WackoWolf in forum C++ Programming
    Replies: 4
    Last Post: 10-12-2005, 05:18 PM
  2. Pi Calculation
    By EvilGuru in forum C Programming
    Replies: 2
    Last Post: 05-02-2005, 04:25 AM
  3. calculation
    By coo_pal in forum C Programming
    Replies: 2
    Last Post: 02-09-2003, 11:41 PM
  4. How to modify a menu into a menu Folder(contains submenus) ??
    By L.O.K. in forum Windows Programming
    Replies: 3
    Last Post: 01-09-2003, 02:26 PM
  5. Calculation Help
    By reddtee in forum C Programming
    Replies: 19
    Last Post: 11-24-2001, 04:17 PM

Tags for this Thread