Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Learn by Example - Java Sample Programs

Shopping List

Book navigation

  • Armstrong Number
  • Palindrome Checking
  • Playing Audio Clip using Applet
  • Applet Form
  • Exception Handling
  • Multiple Inheritance and Packages
  • Shopping List
  • Simple Multithread program
  • JDBC Program Select, Insert, Update, Delete records
  • RMI - Example AddServer
  • Simple Bank Account Process
  • TCP Server and Client in Java
  • UDP Server and Client in Java
  • FTP Server and Client in Java
  • Chat Server and Client in Java
  • Echo Server and Client in Java
  • Address Resolution Protocol in Java
  • Ping server and Client in Java
  • Multicast Server and Client in Java
  • Transposition Cipher Method
  • Poly-alphabetic Cipher Method Encryption - Java
  • DES - Using Data Encryption Standard in Java
  • AES - Using Advanced Encryption Standard in Java
  • Bit Stuffing
By Karthik , 25 November, 2011

import java.io.*;
import java.util.*;
class shop
{
    DataInputStream ds = new DataInputStream(System.in);

    void append(Vector v1) throws IOException
    {
            System.out.println("Enter the element to be Appended");
            System.out.println("Current capacity :"+ v1.capacity());
            v1.insertElementAt(ds.readLine(),v1.capacity());
            System.out.println("Append Successfully");

    }
    void insert(Vector v1) throws IOException
    {
        System.out.println("Enter the position to be inserted");
        Integer x2 = new Integer(ds.readLine());
        Integer pos = x2.intValue();
        System.out.println("Enter the element");
        v1.insertElementAt(ds.readLine(), pos);
            System.out.println("Inserted Successfully");
    }
    void delete(Vector v1) throws IOException
    {
    System.out.println("Enter the position to be deleted");
        Integer x1 = new Integer(ds.readLine());
        Integer pos = x1.intValue();
        v1.removeElementAt(pos);
        System.out.println("Deleted Successfully");

    }
    void display(Vector v1) throws IOException
    {
    int i=0;
    Enumeration vEnum = v1.elements();
    System.out.println("\t\t\t Shopping List");
    System.out.println("-----------------------");
    System.out.println("Items in Vector");
    System.out.println("Position          Item");
    while(vEnum.hasMoreElements())
    {
        System.out.println(i+"\t\t" +vEnum.nextElement());
        i++;

    }



    }


}
class shoppinglist {
    public static void main(String arg[]) throws IOException
    {
        Vector v = new Vector(5,10);
        shop ob = new shop();
        DataInputStream ds = new DataInputStream(System.in);
        for (int i=0; i<arg.length; i++)="" {="" v.addelement(arg[i]);="" }="" ob.display(v);="" while(true)="" system.out.println("\t\t\t="" shopping="" list");="" ----------------");="" system.out.println("1.="" append");="" system.out.println("2.="" delete");="" system.out.println("3.="" insert");="" system.out.println("4.="" display");="" system.out.println("5.="" exit';");="" system.out.println("enter="" ur="" choice");="" int="" ch="Integer.parseInt(ds.readLine());" switch(ch)="" case="" 1:="" ob.append(v);="" break;="" 2:="" ob.delete(v);="" 3:="" ob.insert(v);="" 4:="" 5:="" system.exit(0);="" default:="" correct="" 
  • Add new comment

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy