#include<iostream.h>
#include<conio.h>
#include<process.h>
class item
{
int itemcode[50];
float itemprice[50];
int count;
public :
void cnt(void) { count = 0 ; } // initializes count to 0
void getitem(void);
void displaysum(void);
void remove(void);
void displayitems(void);
};
void item :: getitem(void) //assign values to data members of item
{
cout<<"Enter item code : ";
cin>>itemcode[count];
cout<<"Enter item cost : ";
cin>>itemprice[count];
count++;
}
void item :: displaysum(void) //display total value of all items
{
float sum = 0;
for(int i = 0; i<count; i++)
sum=sum + itemprice[i];
cout<<"\n Total value :"<<sum<<"\n";
}
void item :: remove(void) //deleting a specified item
{
int a;
cout<<" Enter item code : ";
cin>>a;
for(int i = 0; i<count; i++)
if (itemcode[i] == a)
itemprice[i] = 0;
}
void item :: displayitems(void) //displaying items
{
cout<<"\n Code Price \n ";
for(int i = 0; i<count; i++)
{
cout<<"\n"<<itemcode[i];
cout<<" "<<itemprice[i];
}
cout<<"\n";
}
int main( )
{
item I;
I.cnt( );
int ch;
do
{
cout<<"\n Option are……. \n";
cout<<"\n1. Add an item ";
cout<<"\n2. Display total value ";
cout<<"\n3. Delete an item";
cout<<"\n4. Display all items ";
cout<<"\n5. Exit";
cout<<"\n\n Enter your choice : ";
cin>>ch;
switch(ch)
{
case 1 : I.getitem( ); break;
case 2 : I.displaysum( ); break;
case 3 : I.remove( ); break;
case 4 : I.displayitems( ); break;
case 5 : exit(0);
default : cout<<"\n Error in input; try again \n";
}
} while(ch !=5);
}
6 comments:
error on last line
using namespace std; is missing
If we talk about printers first name comes in our head is Brother Printers, for latest and updated Drivers for Brother go to the Following Sites.
solutions.brother.com/windows
solutions.brother.com/windows
solutions.brother.com/windows
solutions.brother.com/windows
goyard bags
hermes bag outlet
golden goose outlet
bape hoodie
golden goose sale
yeezy 350
goyard tote bag
goyard bag
off white shoes
supreme clothing
Post a Comment