import java.io.DataInputStream;
class Items
{
int itemcode[]=new int[10];
int itemcoast[]=new int[10];
int rem;
int i,coast,counter;
try
{
//Input Items
void getitem()
{
System.out.println("Enter the item code");
itemcode[counter]=Integer.parseInt(d.readLine());
System.out.println("Enter the item cost");
itemcost[counter]=Integer.parseInt(d.readLine());
counter++;
}
//Total price
void sumitemcoast()
{
for(i=0;i<counter;i++)
{
coast=coast+itemcoast[i];
}
}
//to display current items and its coast
void display()
{
System.out.println("Item code And Item Coast");
for(i=0;i<counter;i++)
{
System.out.println(itemcode[i]+" "+itemcoast[i]);
}
}
//remove item
void remove()
{
System.out.println("Enter the item code you want to remove");
rem=Integer.parseInt(d.readLine());
for(i=0;i<counter;i++)
{
if(itemcode[i]==rem)
{
itemcoast[i]=0;
break;
}
}
}
}
catch (Exception e) { }
}
//main
class Allitem
{
public static void main(String args[])
{
DataInputStream d=new DataInputStream(System.in);
Items I=new Items();
try
{
System.out.println("Press 1 to Enter Data \n Press 2 to display Item and Coast \n Press 3 to get total item coast \n Press 4 to remove item");
x=Integer.parseInt(d.readLine());
do
{
switch(x)
{
case 1:I.getitem();
break;
case 2:I.display();
break;
case 3:I.sumitemcoast();
break;
case 4:I.remove();
break;
}
System.out.println("Enter 1 to stop or 0 to continue");
int w=Integer.parseInt(d.readLine());
}
while(w!=0);
}
catch (Exception e){}
}
}