Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Menu, how to put calculation in there (http://www.go4expert.com/forums/menu-calculation-t27453/)

khelly 27Dec2011 10:41

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.
Quote:


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?

khelly 27Dec2011 10:47

Re: Menu, how to put calculation in there
 
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

khelly 28Dec2011 15:18

Re: Menu, how to put calculation in there
 
seriously anybody?

xpi0t0s 29Dec2011 13:59

Re: Menu, how to put calculation in there
 
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.


All times are GMT +5.5. The time now is 20:53.