New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Software to add, delete and print an item in shopping list in java


Posted Date:     Total Responses: 0    Posted By: hasmukh   Member Level: Bronze   Points/Cash: 4   


import java.util.*;
import java.io.DataInputStream; // to load DataInputStream class

class P34
{
public static void main(String args[ ])
{
Vector v = new Vector(5,2);
int count=0,i,choice, position;
String str = new String();
boolean flag = false;
String ans = "yes";
DataInputStream in = new DataInputStream(System.in);
count =args.length;
for(i=0;i v.addElement(args[i]);
try
{
System.out.println("\n*********** Super Market **********\n");
do
{
System.out.println("\nSelect Any option (1 to 5)");
System.out.println("\t1. Delete an item ");
System.out.println("\t2. Add an item at a specific location ");
System.out.println("\t3. Add an item at the end of the list ");
System.out.println("\t4. Display Shopping List ");
System.out.println("\t5. Exit ");
choice = Integer.parseInt(in.readLine());
System.out.println();
switch(choice)
{
case 1:
/* Delete an Item */
System.out.print("Enter the item which you want to delete from shopping list : ");
str = in.readLine();
flag = v.removeElement(str);
if(flag==false)
System.out.println(" Item is not in the shopping list");
break;
case 2:
/* Add an item at a specific location */
System.out.print("Enter the item which you want to add in shopping list : ");
str = in.readLine();
System.out.print("Enter a specific location where you want to add an item : ");
position = Integer.parseInt(in.readLine());
v.insertElementAt(str,position-1);
break;
case 3:
/* Add an item at the end of the list */
System.out.print("Enter the item which you want to add in shopping list : ");
str = in.readLine();
v.addElement(str);
break;
case 4:
/* Display Shopping List */
Enumeration vEnum = v.elements();
System.out.println("\nItems in Shopping list are:");
while(vEnum.hasMoreElements())
System.out.println("\t"+vEnum.nextElement() +" ");
//System.out.println();
break;
default:
System.exit(0);
}
System.out.print("Do you Want to continue ? (Yes/No) : ");
ans=in.readLine();
}while(ans.equalsIgnoreCase("yes"));

}
catch(Exception e) { System.out.println("I/O Error"); }

}
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: To create Bank software using Java
Previous Project: Type of Triangle

Return to Project Index

Post New Project


Related Projects


Advertise Here


Watch TV Channels




Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.