a program to add,display,remove items :
solution I did
package com.TestJava;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
const int m=50;
public : class items
{
int itemcode[m];
float itemprice[m];
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 items :: getitem(void) //assign values to data members of item
{
System.out println("Enter the item code:");
catch(itemcode[count]);
System.out println("Enter item cost");
catch(itemprice[count]);
count++;
}
void items ::displaysum(void) //display total values of all items
{
float sum=0;
for(int i=0;i<count;i++)
sum=sum+itemprice[i];
System.out println("\n total value :" <<sum<< "\n");
}
void items :: remove(void) //delete the specific item
{
int a;
System.out println("Enter the item code";
catch(a);
for (int i=0;i<count;i++)
if(itemcode[i] ==a)
itemprice[i] =0;
}
void items :: displayitems(void) //displaying item
{
System.out println("\n code price \n");
for (int i=0;i<count; i++)
{
<<"\n" <<itemcode[i];
System.out println(" " <<itemprice[i]);
}
System.out println("\n");
}
//===================================…
int main()
{
items order;
order.cnt();
int x;
do //do .... while loop
{
System.out println("\n you can do following \n Enter sppropriate number \n");
System.out println ("\n1 :Add an ite");
System.out println ("\n2 : Display total value");
System.out println ("\n3 : delete an item");
System.out println ("\n4 : display all item");
System.out println ("\n5 : Quit");
System.out println ("\n\n what is your option?");
catch(x);
switch(x)
{
case 1 : order.getitem();
break;
case 2 : order.displaysum();
break;
case 3 : order.remove();
break;
case 4 : order.displayitems();
break;
case 5 : break;
default : System.out println("Error in input; try again\n");
}
}
while(x !=5); //do ...while ends
return 0;
}
}