Thread: To call file

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

    To call file

    at first, plec correct me this one...
    Code:
        std::string explanation; // this upper coding
            char explanation; //after entering void to display
    
    if(item_code=='A')
        explanation='BABY WEAR';
    else if(item_code=='B')
        explanation='CHILDREN WEAR;
    else if(item_code=='A')
        explanation='LADIES WEAR';
    else if(item_code=='A')
        explanation='MENSWEAR';
    BABY WEAR and others was error, what should i put?

    plz correct my coding above one first, it it was take long time to solve coding down there.
    sorrt, bcoz i really dont know..

    plz correct me, im running my coding right now with non-stop study, and always refresh this page...

    this is of mine that full, the new one...

    Code:
    #include<iostream>
    #include<fstream>
    #include<cstdlib>
    #include<iomanip>
    #include<string>
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    struct RECORD
    {
        std::string item_code;
        std::string item_number;
        std::string explanation;
        double price;
    }input[10000];
    
    void addRecord(RECORD input[], int &arraycounter);
    void printRecord(RECORD input[]);
    void printAllRecord(RECORD input[]);
    
    int main()
    {
        std::fstream submit;
        submit.open("jualan.dat",std::ios::in);
        submit.seekg(0, std::ios::beg);
        int arraycounter=0;
    
        do
        {
            submit>>input[arraycounter].item_number>>input[arraycounter].item_code>>input[arraycounter].price;
            arraycounter++;
        }
        
        while(submit.good());
        submit.close();
        arraycounter--;
        {
            int menuEnter;
            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 categories\n";
                    cout<<" 4 = Exit";
                    cout<<"\nEnter Menu Number : ";
                    cin>>menuEnter;
    
                    if(menuEnter==1)
                        addRecord(input, arraycounter);
                    else if (menuEnter==2)
                        printRecord(input);
                    else if (menuEnter==3)
                        printAllRecord(input);
                }
                    while (menuEnter!=4);
            return 0;
        }
        
           void addRecord(RECORD input[], int arraycounter);
           {
            char item_code; // code category
            char item_number;  // code number category
    
            cout<<"Enter code category : \n";
            cin>>input[arraycounter].item_code;
            cout<<"Enter code number of category : \n";
            cin>>input[arraycounter].item_number;
            arraycounter++;
           }
        
        void printRecord(RECORD input[]);
        {
            char item_code, item_number;
            char explanation;
            float price, total_sales;
            
            cout<<"Please enter category code : "<<endl;
            cin>>item_code;
                if(item_code=='A')
                    explanation==BABY WEAR;
                else if(item_code=='B')
                    explanation='CHILDREN WEAR';
                else if(item_code=='A')
                    explanation='LADIES WEAR';
                else if(item_code=='A')
                    explanation='MENSWEAR';
    
            cout<<"SALES REPORT FOR "<<explanation<<endl;
            cout<<"\nItem Number\t\tPrice" << endl;
            cout<<"------------------------------"<<endl;
            cout<<item_code<<item_number<<"\t\t"<<price<<endl;
            cout<<"------------------------------"<<endl;
            cout<<"Total Sales\t\t"<<total_sales<<endl;
            cout<<endl;
    
    switch(item_code)
    {
        case'A':
        if(item_number==101)
        {
            price=10.00;
        }
        if(item_number==102)
        {
            price=5.00;
        }
        break;
        
        case'B':
        if(item_number==101)
        {
            price=12.00;
        }
        if(item_number==104)
        {
            price=20.00;
        }
        if(item_number==105)
        {
            price=20.00;
        }
        break;
        
        case'C':
        if(item_number==103)
        {
            price=12.00;
        }
        break;
        
        case'D':
        if(item_number==101)
        {
            price=12.00;
        }
        break;
    }
        }
        
        void printAllRecord(RECORD input[]);
        {
            cout<<"SALES REPORT FOR ALL CATEGORIES"<<endl;
            cout<<"\nCategory\t\tSales" << endl;
            cout<<"------------------------------"<<endl;
            cout<<explanation<<"\t\t"<<price<<endl;
            cout<<"------------------------------"<<endl;
            cout<<"Total Sales\t\t"<<totalSales<<endl;
            cout<<endl;
    }
    this is the question. no.1, no problem, but no 2, and 3, but also 4. how to exit? but no1, does can repeat or back to menu? bcoz to add many record?

    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.

  2. #2

  3. #3
    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..
    Last edited by khelly; 12-28-2011 at 06:39 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You know, if you put as much effort into learning the material as you do into finding new places to dump your homework, you might actually achieve something.

    To call file - CodingForums.com
    Menu, how to put calculation in there - CodeGuru Forums
    Can anyone help me???
    C FILE, Family Outfit Shop decided to create a computerized system t | Cramster.com
    And others....

    You're wasting too much time tracking inconsistent replies across multiple forums to ever achieve anything worthwhile.

    Now read THIS -> How To Ask Questions The Smart Way
    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.

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    @Salem, oh my god...

    u did notice...

    now i'm afraid..
    ihave my new coding, i almost done...

    PLEASE DONT SAY THAT IM WASTING MY EFFORT, IM JUST STUDYING WITH PPL, NOT ALONE...

    By the way, 1st and 1nd link is mine, but 3rd and 4th is not ME...
    Can anyone help me???
    C FILE, Family Outfit Shop decided to create a computerized system t | Cramster.com

    who is it could be?

    dont know who but i believe it was IN SAME COURSE...

    dont say i'm lazy, im about done my coding.. this how im study, i have no time to arguing..

    now i'm afraid to post my new coding bcoz they might steal it..
    NO WAY... now way, i do it on my own!

    This is group project, but like a hell my groupmate pointless about this project, use her sick grandmother to skip project... and the rest very slow, doesnt show any affrt or interest...

    EVEN I'M WASTING MY EFFORT AS U THINK, AT LEAST IM USING MY EFFORT....

    i'm not that smart... thats why im here, but i'm not lazy !

  6. #6
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    that people in no3 and no4 does not include their draft coding...

    at least i DID!
    MINE!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to call an exe file in a c# program?
    By arian in forum C# Programming
    Replies: 8
    Last Post: 02-06-2011, 11:30 AM
  2. Trying to call an Excel file
    By LuckyDrawers17 in forum C++ Programming
    Replies: 3
    Last Post: 06-11-2008, 07:33 PM
  3. how to call a C function from another file
    By rameshs in forum C Programming
    Replies: 2
    Last Post: 11-09-2006, 06:35 AM
  4. Call an exe file under VC
    By abu in forum Windows Programming
    Replies: 2
    Last Post: 07-20-2004, 06:01 AM
  5. System call to call another C file from Existing C File
    By simly01 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2002, 01:29 PM