Write a program to prepare a shopping lists

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
const size=3;
class item
{
    private:
      char name[25];
      int qty;
      float rate,amount;
    public:
      void getdata()
      {
        cout<<endl<<"Enter the item name:";
        cin>>name;
        cout<<"\nEnter the Rate:";
        cin>>rate;
        cout<<"\nEnter the Quantity:";
        cin>>qty;
      }
      void printdata()
      {
         cout<<setw(5)<<name;
         cout<<setw(5)<<rate;
         cout<<setw(5)<<qty;
         amount=rate*qty;
         cout<<setw(8)<<amount<<endl;
      }
};
void main()
{
   item shop[size];
   clrscr();
   for(int i=0;i<size;i++)
   shop[i].getdata();
   cout<<"Shopping List"<<endl;
   cout<<"Name Quantity Rate Amount\n";
   for(i=0;i<size;i++)
   shop[i].printdata();
   getch();
}

10 comments:

  1. Replies
    1. Nothing wrong save it as .cpp instead of c then try

      Delete
  2. I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. 성인용품창업

    ReplyDelete
  3. I am happy with the program no errors found

    ReplyDelete
  4. rate needs to be given by program itself not by user

    ReplyDelete