Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » BeginnersRSS Feeds

Simple Inventory Program

Posted By: Easy Tutor     Category: C++ Programming     Views: 16456

A simple program to display inventory records in c++

Code for Simple Inventory Program in C++ Programming

#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#define MAX_REC 10

class Inventory{
    char itemName[15];
    int code;
    double cost;
    public:
    void getdata();
    void showdata();
};

void Inventory :: getdata(){
    cout<<"\nEnter Item Name : ";
    cin>>itemName;
    cout<<"Enter Code : ";
    cin>>code;
    cout<<"Enter Cost : ";
    cin>>cost;
}

void Inventory :: showdata(){
    cout<<endl;
    cout.width(15);
    cout.setf(ios::left, ios::adjustfield);
    cout<<itemName;

    cout.width(8);
    cout<<code;

    cout.width(15);
    cout.setf(ios::right, ios::adjustfield);
    cout.setf(ios::showpoint);
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(2);
    cout<<cost;
}

void main(){
    Inventory record[MAX_REC];
    int i,n;
    clrscr();

    cout<<"\n=====Inventory Management=====\n";
    cout<<"\nHow many Records to be created : ";
    cin>>n;

    cout<<"Enter "<<n<<" Records\n";
    for(i=0;i<n;i++)
        record[i].getdata();

    cout<<"\n\n---Stock Information---\n";
    cout<<"\n"<<setw(8)<<"Item Name"
        <<setw(10)<<"Code"
        <<setw(19)<<"Cost"<<endl;
    cout<<"-------------------------------------------";

    for(i=0;i<n;i++)
        record[i].showdata();

    getch();
}[/Code]
  
Share: 


Didn't find what you were looking for? Find more on Simple Inventory Program Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Simple Inventory Program is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!