//PROGRAM FOR THE SHOOPING LIST
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
const m=50; //HERE THE CLASS BEGINS
class items
{
int itemcode[m];
float itemprice[m];
int count;
public:
void cnt(void)
{
count=0;
}
void getitem(void);
void displaysum(void);
void remove(void);
void displayitems(void);
}; //here the class ends
void items::getitem(void)
{
cout<<"enter the item code\n";
cin>>itemcode[count];
cout<<"\nenter the item price\n";
cin>>itemprice[count];
count++;
}
void items::displaysum(void)
{
float sum=0;
for(int i=0;i<count;i++)
sum+=itemprice[i];
cout<<"\ntotal value\t"<<sum<<"\n";
}
void items::remove(void)
{
int a;
cout<<"\nenter the item code \n";
cin>>a;
for(int i=0;i<count;i++)
if(itemcode[i]==a)
itemprice[i]=0;
}
void items::displayitems(void)
{
cout<<"\ncode\tprice\n";
for(int i=0;i<count;i++)
cout<<itemcode[i]<<"\t"<<itemprice[i]<<"\n";
}
//---------------------------------------------
void main() //HETE THE MAIN BEGINS
{
clrscr();
items order;
order.cnt();
int x;
do //do.while loop
{
cout<<"\nyou can do the following\n";
cout<<"enter the appropriate number\n";
cout<<"1: add an item\n";
cout<<"2: display total value\n";
cout<<"3: delete an item\n";
cout<<"4: display all items\n";
cout<<"5: quit\n";
cout<<"what us your option \n";
cin>>x;
switch(x) //switch begins
{
case 1: order.getitem(); break;
case 2: order.displaysum(); break;
case 3: order.remove(); break;
case 4: order.displayitems(); break;
case 5: break;
default : cout<<"\nerror in input; try again\n";
} //SWITCH ENDS
}while(x!=5); //DO WHILE ENDS
} //MAIN ENDS HERE
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
const m=50; //HERE THE CLASS BEGINS
class items
{
int itemcode[m];
float itemprice[m];
int count;
public:
void cnt(void)
{
count=0;
}
void getitem(void);
void displaysum(void);
void remove(void);
void displayitems(void);
}; //here the class ends
void items::getitem(void)
{
cout<<"enter the item code\n";
cin>>itemcode[count];
cout<<"\nenter the item price\n";
cin>>itemprice[count];
count++;
}
void items::displaysum(void)
{
float sum=0;
for(int i=0;i<count;i++)
sum+=itemprice[i];
cout<<"\ntotal value\t"<<sum<<"\n";
}
void items::remove(void)
{
int a;
cout<<"\nenter the item code \n";
cin>>a;
for(int i=0;i<count;i++)
if(itemcode[i]==a)
itemprice[i]=0;
}
void items::displayitems(void)
{
cout<<"\ncode\tprice\n";
for(int i=0;i<count;i++)
cout<<itemcode[i]<<"\t"<<itemprice[i]<<"\n";
}
//---------------------------------------------
void main() //HETE THE MAIN BEGINS
{
clrscr();
items order;
order.cnt();
int x;
do //do.while loop
{
cout<<"\nyou can do the following\n";
cout<<"enter the appropriate number\n";
cout<<"1: add an item\n";
cout<<"2: display total value\n";
cout<<"3: delete an item\n";
cout<<"4: display all items\n";
cout<<"5: quit\n";
cout<<"what us your option \n";
cin>>x;
switch(x) //switch begins
{
case 1: order.getitem(); break;
case 2: order.displaysum(); break;
case 3: order.remove(); break;
case 4: order.displayitems(); break;
case 5: break;
default : cout<<"\nerror in input; try again\n";
} //SWITCH ENDS
}while(x!=5); //DO WHILE ENDS
} //MAIN ENDS HERE
No comments:
Post a Comment