Developing a shopping cart in java please help

Implement a shopping cart with following features.
1. Create items with required attributes.
2. Define shopping cart parameters
3. define stock values
4. Create an order
5. add to cart
6. Copy cart
7. remove item from cart
8. Check out
9. Print history.

dhaval_shah wrote:
What do you need help with?he's ordering you to do it for him. Not even a "please" to make it sound like a request.
Of course we're not anyone's homework service (though a lot of kids seem to be under the impression that we are) so the kid can expected to be flamed and made fun of (which will likely lead to him getting agressive and abusive, leading to even more fun for us regulars and his eventual bannishment).

Similar Messages

  • Please help me to develop a shopping cart in java

    I want to develop a simple shopping cart application where a particulart owner can add the items, and the user have to select the item code and the quantity he needs. These are the things i need.
    Implement a shopping cart with following features.
    1. Create items with required attributes.
    2. Define shopping cart parameters
    3. define stock values
    4. Create an order
    5. add to cart
    6. Copy cart
    7. remove item from cart
    8. Check out
    9. Print history.
    i'm so cunfused. Please help me.

    /* This program will add the product code,name,and the price of the items
    import java.io.*;
    import java.util.*;
    public class AddingItems
         public String code,name;
         public static float price;
         LinkedList olist=null;
         public AddingItems(String code,String name,float price)
         this.code=code;
         this.name=name;
         this.price=price;
         public Object getUserInput()
         System.out.println();
         GetInput gi=new GetInput();
         int number=gi.getInteger(" Enter the number of items you want to add to the system : ");
         System.out.println();
         System.out.println();
         olist=new LinkedList(); //declaring the array length according to the user input
              for(int i=0;i<number;i++)
                   System.out.println(" **** Enter The Product Details *** ");
                   System.out.println();
                   GetInput gicode=new GetInput();
                   code=gicode.getString("\t Enter the product code : ");
                   GetInput giname=new GetInput();
                   name=giname.getString("\t Enter the name of the product :");
                   GetInput giprice=new GetInput();
                   price=giprice.getInteger("\t Enter the product price in Rs. :");
                   // creating an object of the AddingItems class
                   AddingItems items=new AddingItems(code,name,price);
                   // the value input from the user to the system is now assigned to the array created with the length given by the user
                   olist.add(items);
              return olist;
              public void display()
              System.out.println();
              System.out.println("\t\t\t*** These are the products in the system **** ");
              System.out.println();
              System.out.println("\t\t\t Product Code \t\t\t Product Name \t\t\t Price in Rs.");
              System.out.println();
              for(int i=0;i<olist.size();i++)
              AddingItems items=(AddingItems)olist.get(i);
              System.out.println("\t\t\t "+items.code+"\t\t\t\t "+items.name+"\t\t\t\t "+items.price);
              System.out.println();
              /*public void addItemsToCart()
              System.out.println();
              GetInput input=new GetInput();
              System.out.println();
              String selection=input.getString("Do you want to continue adding the products to your shopping cart ? [y]es,[N]o : ");
              System.out.println();
              switch(selection.charAt(0))
                   case 'y':
                   case 'Y':
                   System.out.println();
                   System.out.println("Enter the products and the quantities you want to add to your shopping cart :");
                   System.out.println("........................................................................... ");
                   LinkedList myList=null;
                   break;
                   case 'n':
                   case 'N':
                   System.out.println();
                   String message=" You are about to log off from the system: ";
                   System.out.println(message);
                   break;
                   default:
    public static void main(String[] args)
    AddingItems items=new AddingItems("code","name",price);
    //AddingItems[] additems=(AddingItems)items.getUserInput();
    items.getUserInput();
    items.display();
         /*GetInput input=new GetInput();
         System.out.println();
         String selection=input.getString("Do you want to continue adding the products to your shopping cart ? [Y]es,[N]o : ");
         System.out.println();
         switch(selection.charAt(0))
              case 'y':
              case 'Y':
              System.out.println();
              System.out.println(" Enter the code of the product and the quantity you want to add to the shopping cart ");
              String code=null;
              int quantity=0;
              double total=0.0;
              LinkedList myList=new LinkedList();
              GetInput itemc=new GetInput();
              String itemcc=itemc.getString();
              //GetInput list=new GetInput();
              Scanner sc=new Scanner(System.in);
              System.out.println(" .............. Enter the code and the quantity you wamt to add to your shopping cart");
              System.out.println();
              System.out.println();
              //while(sc.equals(item.code))
              Scanner c=nextString();
              //GetInput list=new GetInput();
              //AddingItems items=new AddingItems("code");
              //String listcode=list.getString("Enter the item code :");
              if(listcode==olist.contains(true))
              myList.add(listcode);     
              GetInput list2=new GetInput();
              //int listquantity=list2.getInteger("Enter the quantity :");
              //myList.add(listquantity);     
              System.out.println("Do you want to continue ");
              break;
              case 'n':
              case 'N':
              System.out.println();
              String message=" You are about to log off from the system: ";
              System.out.println(message);
              GetInput select=new GetInput();
              System.out.println();
              String need=select.getString("Do you want to proceed ? [o]k ,gnore : ");
              case 'o':
              case 'O':
              System.exit(1);
              break;
         default:
              //GetInput input=new GetInput();
         //code=
    this is i did using the linked list to add the items to the shopping cart but now i'm so stuck that i can't search for the product code where the user adds is there in the list which is added by the owner. pls help

  • Pascal to Java Please help me!

    I am truobled in creating a validation method for the user loging in....
    As I am perfect at Pascal can anyone translate the following pascla code to Java Please help me with this.
    PROGRAM USERLOGIN;
    TYPE
      USER_TYPE = RECORD
        USERNAME : STRING[15];
        PASSWORD : STRING[15];
    END;
        USFILE = FILE OF USER_TYPE;
    VAR
       USER: USER_TYPE;
       CKUSER: USER_TYPE;
       RECFILE : USFILE;
       I,J     : INTEGER;
    BEGIN
    WRITE('ENTER USERNAME:');READLN(CKUSER.USERNAME);
    WRITE('ENTER PASSWORD:');READLN(CKUSER.PASSWORD);
    FILESPEC :='USERFILE.USR';
    ASSIGN(RECFILE, FILESPEC);
    RESET(RECFILE);
      WHILE NOT EOF(RECFILE) DO
       BEGIN
         READ(RECFILE, USER);
         IF CKUSER.USERNAME = USER.USERNAME AND CKUSER.PASSWORD = USER.PASSWORD THEN
              LOGIN
        ELSE
              WRITE('USER NOT FOUND');
       END;
    END.Thank you

    Don't bother:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=539277

  • Why the same name of process comes out in AIX , in java. please help me.

    Hello.
    I have two questions related to Jvm.
    I've developed Job scheduler program which is doing somthing as the DB schedule is set in the way of Multi
    thread. Currently , I'm in the process of testing this one. It is good , if in the normal case. However, When
    doing Shell, if the application have so a lot to do the Shell, it has a little problem.
    My developing environment is
    OS : AIX 5.3
    JRE : IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr7-20091214_49398
    (JIT enabled, AOT enabled)
    nofiles(descriptors) 2000
    maxuproc 4096 Maximum number of PROCESSES allowed
    per user True
    In order to execute Shell in My Scheduler program , I tested Runtimeexec() or ProcessBuilder.
    The result of mine in the test , when the executed Shell got over 300 is
         1. The jvm processes that I execute at the first time are shown up , after Shell go to the finish, the
    processes are all in the disappearance again , and at last The processes that I executed at the first time are
    remaining. It's like the process is duplicated process in the maximum of 70.
    When I do shell about 200 to be executed simultaneously, Duplicated jvm about 3 appeared momentarily, then
    disappeared, and also under 120, No duplicated case is found when under 120.
    ps -ef result is below , when shell is excuted
    UID PID PPID C STIME TTY TIME CMD
    jslee 626906 1 0 11, May - 2:20 java -
    DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    jslee 1421522 626906 0
    19:36:16 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    ....Skip.....
    jslee 4374620 626906 0 19:34:06 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -
    Dfile.encoding=euc-kr jobserver.JobServerMain
    (the process list about 60)
    *the first question : Why a lot of duplicated jvm are shown up when in alot of shell to be executed ?
    *the second question : As you can see above , How can I solve out the problem.
    *Is there some option that I can set up when starting Jvm?
    ---Next question---
    My developing environment is
    OS : SunOS 5.8
    JRE : Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
    Java HotSpot(TM) Server
    VM (build 16.0-b13, mixed mode)
    nofiles(descriptors) 256
    As shown obove , the value of descriptors is 256 .
         My scheduler program executed 300 shell at the same time, in result my program was abnormalily
    terminated after doing shell about 180.
    the Exception info is
    java.io.IOException: Cannot run program "sh": error=24, exceeding the number of opened files
         at
    java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at
    java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    or
    java.net.SocketException: exceeding the number of opened files     at java.net.PlainSocketImpl.socketAccept
    (Native Method)
    &#46608;&#45716;
    java.io.IOException: exceeding the number of opened files     at
    java.io.UnixFileSystem.createFileExclusively(Native Method)
         at java.io.File.checkAndCreate(Unknown
    Source)
         at java.io.File.createTempFile(Unknown Source)
    *question : If I continuously request to open a file that go over system limit, is it possible for JVM to be
    terminated?
    *question : Is there a method that obtains state of System limit in the java library.
    *question : what is the best solution to cope with ?
    Please help me
    =

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationAction" // action class
                   name="registrationForm" // form bean name
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>HTH

  • Trouble with remove item fro shopping cart.. Pls Help..

    hi.. i'm an amatuer student who just learnt abt JSP.. i was given a project tot do shopping cart.. and it's due soon.. i need help regarding my codes.. i try so many methods but it doesn't work.. there is problem with my remove item.. when i try to remove an item.. it does not remove the item.. can somebody help me with my codes.. is there something wrong with my JavaBeans??
    i have 2 javafiles..
    Product.java
    package product;
    public class Product {
         String id, name, size, colour, other;
         int quantity;
         double price, total;
         public Product(String newid, String newname, String newsize, String newcolour, String newother, double newprice, int newqty)
         //public Product(String newid, String newname, double newprice)
              id= newid;
              name= newname;
              size= newsize;
              colour= newcolour;
              other = newother;
              price = newprice;     
              quantity= newqty;
         public String getId()
              return id;
         public String getName()
              return name;
         public String getSize()
              return size;
         public String getColour()
              return colour;
         public String getOther()
              return other;
         public int getQuantity()
              return quantity;
         public double getPrice()
              return price;
         public double getTotal()
              return (price*quantity);
    ShoppingCart .java
    package product;
    import java.util.*;
    public class ShoppingCart {
           int noItems = 0;
         Vector products = new Vector();
              public void addProduct(Product i){               
                   products.addElement(i);     
              public void deleteProduct(String id){
               Enumeration productEnum = getProducts();
                   while(productEnum.hasMoreElements()){
                             Product product = (Product)productEnum.nextElement();
                             if(product.getId().equals(id)){                                             
                                  //products.removeElement(id);
                                  products.removeElement(product.id);
                                  break;                         
              public void emptyCart(){
                   products.clear();
              public int getNoProducts(){
                   return products.size();     
              public Enumeration getProducts(){
                   return products.elements();
              public double getTotal(){
                   Enumeration productEnum = getProducts();
                   double total=0;
                        while(productEnum.hasMoreElements()){
                             Product product = (Product)productEnum.nextElement();
                             total = total + product.getTotal();
                        return total;
    viewsc1.jsp
    <%@page import="java.util.*"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="IBM WebSphere Studio">
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>viewsc1.jsp</TITLE>
    </HEAD>
    <BODY>
    <jsp:useBean id="sCart" class="product.ShoppingCart" scope="session"/>
    <%@page import="product.Product"%>
         <table width="80%" border="0" align="center">
           <tr>
             <td align="center"><img src="image/title.jpg" width="450" height="80"></td>
           </tr>
           <tr>
             <td align="center" height="90"> </td>
           </tr>
           <tr>
             <td align="center" height="210">
                 <table width="98%" border="1" height="142">
                   <tr>
                     <td height="129">
                       <table border="0" width="100%">
                         <tr>
                           <td colspan="9" bgcolor="#CCCC99" align="center" height="22">
                             <img src="image/vsc.jpg" width="300" height="50">
                           </td>
                         </tr>
                         <tr>
                           <td height="15" colspan="9"></td>
                         </tr>
    <%
    String name= request.getParameter("name");
    if(name!= null){
         if(name.equals("Empty")){
              sCart.emptyCart();
    %>     
              <SCRIPT>
                alert("Your Shopping Cart is empty."); 
                location.href="chooseCategory.jsp";
            </SCRIPT>
    <%     }else if(name.equals("delete")){
         String index = request.getParameter("Id");
          sCart.removeItem(index);
                   out.println(index);
         }else if (name.equals("update")){
          String[] prodQtys = request.getParameterValues("newQty");
         // sCart.updateQtys(prodQtys);
    if(sCart.getNoProducts()!=0){%>
            <tr>
              <td height="15" align="center" width="20%"><B>Item ID</B></td>         
              <td height="15" align="center" width="20%"><B>Item Name</B></td> 
              <td height="15" align="center" width="11%"><b>Size</b></td>
              <td height="15" align="center" width="9%"><B>Colour</b></td>                               
              <td height="15" align="center" width="13%"><b>Price</b></td>     
              <td height="15" align="center" width="10%"><b>Qty</b></td>
              <td height="15" align="center" width="12%"></td>
              <td height="15" align="center" width="12%"><b>Total:</b></td>
              <td height="15" align="center" width="12%"></td>
            </tr>
    <%     //<FORM action="viewsc1.jsp?name=update" method=POST>
              Enumeration products =sCart.getProducts();
              while(products.hasMoreElements()){
                   Product product = (Product)products.nextElement();
                        if(product.getQuantity()!=0){
              %>
              <tr>        
              <td height="15" align="center" width="20%"><B><%=product.getId() %></B></td> 
              <td height="15" align="center" width="11%"><b><%=product.getName() %></b></td>         
              <td height="15" align="center" width="9%"><B><%=product.getSize() %></b></td>
              <td height="15" align="center" width="9%"><B><%=product.getColour() %></b></td>                                                          
              <td height="15" align="center" width="13%"><b><%=product.getPrice() %></b></td>          
              <td height="15" align="center" width="9%"><input type=text name="newQty" value="<%=product.getQuantity()%>">               
                   <a href="editQty.jsp?id=<%=product.getId() %>&name=<%=product.getName() %>&qty=<%=product.getQuantity()%>">Edit</a>
              </td>
              <td height="15" align="center" width="9%"><B><%=product.getOther() %></b></td>
              <td height="15" align="center" width="10%"><b><%=product.getTotal() %></b></td>
               <td align='center'><a href="viewsc1.jsp?name=delete&Id=<%=product.getId() %>">Remove</a></td>
            </tr>
    <%          }else{ %>
              <tr>        
              <td height="15" align="center" width="20%"><B><%=product.getId() %></B></td> 
              <td height="15" align="center" width="11%"><b><%=product.getName() %></b></td>         
              <td height="15" align="center" width="9%"><B><%=product.getSize() %></b></td>
              <td height="15" align="center" width="9%"><B><%=product.getColour() %></b></td>                                                          
              <td height="15" align="center" width="13%"><b><%=product.getPrice() %></b></td>          
              <td height="15" align="center" width="9%"><B><%=product.getQuantity() %></b></td>     
              <td height="15" align="center" width="9%"><B><%=product.getOther() %></b></td>
              <td height="15" align="center" width="10%"><b><%=product.getTotal() %></b></td>
               <td align='center'><a href="viewsc1.jsp?name=delete&Id=<%=product.getId() %>">Remove</a></td>
            </tr>
    <%     }
         } %>
    <tr>
    <td height="50" valign="bottom" colspan="9" height="15" align="right" width="12%"><b>Total:</b><%=sCart.getTotal() %></td>
    </tr>
    <%
    }else{%>
         <SCRIPT>
                alert("Your Shopping Cart is empty.");
                location.href="chooseCategory.jsp";
            </SCRIPT>
    <%}
    %>
    <tr>
                      <td colspan="9" height="15" align="center">
                           <input type=submit value='Update Quantity'>
                        <a href=chooseCategory.jsp><IMG border="0" src="image/BtnContinueshop.gif" width="153" height="27"></a>
                        <a href="viewsc1.jsp?name=Empty"><IMG border="0" src="image/BtnEmptyBsk.gif" width="75" height="27"> </a>
                        <a href=checkout.jsp><IMG border="0" src="image/BtnCheckOut.gif" width="156" height="27"></a>
                    </td>
                    </tr>
                    </form>
                  </table>
    </BODY>
    </HTML>

    When you insert products, the Product object itself is the element you use.
    public void addProduct(Product i){
         products.addElement(i);     
    }But when you remove the product, you use the ID of the product as the element.
    products.removeElement(product.id);That doesn't seem right, now does it?

  • Can't access iTunes shopping cart.  Who can help?

    For some reason I can not access my iTunes shopping cart. It shows me how much money I have to spend, but I can't see any of the songs that I have added to the shopping cart. Has anyone ever had this problem? Please advise ASAP. I'd like to buy some music.
    Thanks
    Dell   Windows XP  
      Windows XP  

    If your getting some error message Id recommend emailing the music store about this issue, as USUALLY issues with the shopping cart are caused on apples side. you can goto the link below, roll to the bottom and fill out a email form to the music store
    http://www.apple.com/support/itunes/musicstore/download/

  • Very new to java please help

    i'm very new to java and i'm getting an error in my application. i took 4 applications that compiled and worked separatly and i tried to combine them into one application. i'm getting the error: unreported exception java.io.IOException; must be caught or declared to be thrown, in lines 73,78,83,88,120,146,149,152,155 in the and it points at the keyboard.readLine() but everything i've tried just gives me more errors. please help anything and everything will be greatly appreciated. here it is, sorry about format i dunno how to straighten it in here:
    // ^ ^
    //               (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
         static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
         static PrintWriter screen = new PrintWriter(System.out, true);
         public static void main (String[] args) throws IOException
              double hoursa, minutesa, secondsa;
              String hours;
              System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
              System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // An application that finds the distance between two points when the points
    // are given by the user.
              double x1, x2, y1, y2, total, distance;
              String xa;
              System.out.print ("Please enter the 'x' coordinate of first point: ");
              xa = keyboard.readLine();
              x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
              String ya;
              System.out.print ("...also need the 'y' coordinate of first point: ");
              ya = keyboard.readLine();
              y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
              String xb;
              System.out.print ("...and the 'x' coordinate of the second point: ");
              xb = keyboard.readLine();
              x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
              String yb;
              System.out.print ("...don't forget the 'y' coordinate of the second point: ");
              yb = keyboard.readLine();
              y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
              total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
              distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
              System.out.print ("E=mc^2...oh and,");
              System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
              xb + "," + yb + ") is : " + distance);
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
              double radius,volume,area;
              String rad;
              System.out.print("Please enter the radius of a sphere: ");
              rad = keyboard.readLine();
              radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
              volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
              System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
              area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
              System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
              int pennies, nickels, dimes, quarters;
              double money1;
              screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
              int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
              screen.println("How many dimes?: ");
              int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
              screen.println("How many nickels?: ");
              int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
              screen.println("How many pennies?: ");
              int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
              NumberFormat money = NumberFormat.getCurrencyInstance();
              money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
              screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money

    Ok here is the working code as one long function:
    // ^ ^
    // (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
        static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter screen = new PrintWriter(System.out, true);
        public static void main (String[] args) throws IOException
    double hoursa, minutesa, secondsa;
    String hours;
    System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
    System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // }  <----- MAIN FUNCTION USED TO END HERE!!!
    //but we want to keep going so remove the bracket!
    // An application that finds the distance between two points when the points
    // are given by the user.
    // {  <-- other function used to start here, but now it continues
    double x1, x2, y1, y2, total, distance;
    String xa;
    System.out.print ("Please enter the 'x' coordinate of first point: ");
    xa = keyboard.readLine();
    x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
    String ya;
    System.out.print ("...also need the 'y' coordinate of first point: ");
    ya = keyboard.readLine();
    y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
    String xb;
    System.out.print ("...and the 'x' coordinate of the second point: ");
    xb = keyboard.readLine();
    x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
    String yb;
    System.out.print ("...don't forget the 'y' coordinate of the second point: ");
    yb = keyboard.readLine();
    y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
    total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
    distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
    System.out.print ("E=mc^2...oh and,");
    System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
         xb + "," + yb + ") is : " + distance);
    //second function used to end here...
    //} <--- COMMENT OUT BRACKET SO WE CONTINUE
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
    //{ <--- ANOTHER ONE TO COMMENT OUT
    double radius,volume,area;
    String rad;
    System.out.print("Please enter the radius of a sphere: ");
    rad = keyboard.readLine();
    radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
    volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
    System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
    area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
    System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // } <----- COMMENTED OUT FOR THE SAME REASON
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
    //{ <----AND ANOTHER
    int pennies, nickels, dimes, quarters;
    double money1;
    screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
    int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
    screen.println("How many dimes?: ");
    int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
    screen.println("How many nickels?: ");
    int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
    screen.println("How many pennies?: ");
    int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
    NumberFormat money = NumberFormat.getCurrencyInstance();
    money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
    screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money
    }P.S. To make the code formatted better put [ code ] before and [ /code ] after. It's not perfect, but a little better...

  • Develop simple shopping cart using ADDT

    Hi, I'm new here.I just wondering if its possible to develop a very simple shopping cart application using ADDT?Anyone have any ideas?
    I'm thinking to develop a very simple shopping cart with no shipping cost,tax details and all that.Just an image,description of the product and price.All the orders with be send to 1 or many emails.No payment gateway needed.That's it.And of course got basic common shopping cart features like 'Add to cart','Remove item',session, that's all.Any ideas guys?
    Thanks

    Duh, I figured it out.
    <cfset bar = arraydeleteat(SESSION.shoppingcart, i)>
    I am having a problem when looping not sure why. I think
    because I'm deleting an item in the array it tries to loop to that
    index in the array. It will say "The element at position 3 cannot
    be found". I guess I normally wouldn't have to delete multiple
    positions in the array with a normal shopping cart unless they
    selected two different id's. I'll work on a more advanced shopping
    cart and post again.

  • M new to this forum + new to java please help me with file handling program

    hi i want to make a file handling program where in i want to input a text file say f1 whose style is mentioned as below
    aaa...bcd
    aaabbc
    acdce
    a..dd
    abbcd
    now i want to write d out put of file f1 to file f2 but only those string entries widout any ... in them how to do that :-(( please help :((

    import java.io.*;
    import java.lang.*;
    class javcsse{
             void javsce (){
              BufferedReader in;
            PrintWriter out;
            String line;
            try
                in = new BufferedReader(new FileReader("e:\\cntcs\\n7.txt"));
                out = new PrintWriter("e:\\cntcs\\n8.txt");
               line = in.readLine();
               while(line != null)
                     if(line.contains("...") && line.contains("....")){
                         break ;                
                         else{
                               if(line.contains("cc"))
                              System.out.println(line+"\n");
                                      out.println(line);
                    line = in.readLine();
                in.close();
                out.close();
            } catch (Exception ex)
                System.err.println(ex.getMessage());
      public class javcse{
        public static void main(String[] args) {
            new javcsse();
    }hey i wrote this code yet could u tell y is it still not working :((

  • I am new to java please help!!

    please help ive got a method thta i wanto to use it in another class, but it does not work.
    //prueba.java
    import java.io.*;
    public class prueba
    public int numero3;
    public int suma(int numero1,int numero2)
    int numero3=numero1+numero2;
    return numero3;
    //prueba1.java
    import javax.servlet.*;
    import java.io.*;
    import javax.servlet.http.*;
    import prueba;
    public class prueba1 extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    PrintWriter out = res.getWriter();
    int num1=1;
    int num2=1;
    prueba uno=new prueba();
    out.println(uno.suma(2,3));
    when i ty to complie this file it throws me thie errors:
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:4: cannot resolve symbol
    symbol: class prueba
    import prueba;
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
    prueba uno=new prueba();
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
    prueba uno=new prueba();
    ^
    3 errors
    Tool completed with exit code 1
    both , prueba1.java and prueba.java are in the same folder.

    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
         prueba uno=new prueba();
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
         prueba uno=new prueba();
    ^
    2 errors

  • Recursion in java. please help

    I am writing a program for tree traversing as follows. The program is relatively long but please just focus on 2 lines with errors indicated.
    import java.io.*;
    import myBinaryTree;
    class myBinaryTreeTest{
         static int vertexArray[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 3, 3, 7, 9, 11, 5, 11};     
         static myBinaryTree treeArray[] = new myBinaryTree[10];
         static myBinaryTree tree;
         static pTwoChildNode nodeParent, nodeLeft, nodeRight;
         static treeNodeData dataParent, dataLeft, dataRight;
         public static void main(String[] args) {
         for (int j=0; j<10; j++) {
         treeArray[j]=new myBinaryTree();
    boolean treeArrayEmpty;
    int treeArrayEmptyIndex;
    int treeArrayChildIndex, treeArrayParentIndex;
              int vertexCollapseChild, vertexCollapseParent;
              for (int i=0; i<20; i=i+2) {
    vertexCollapseChild=vertexArray;
    vertexCollapseParent=vertexArray[i+1];
    treeArrayEmptyIndex=-1;
    treeArrayChildIndex=-1;
              treeArrayParentIndex=-1;          
              for (int j=0; j<10; j++) {
                   if (treeArray[j].isEmpty()) {
    if (treeArrayEmptyIndex == -1) {
    treeArrayEmptyIndex=j;
    else {
    dataParent = (treeNodeData)treeArray[j].getData();
                   if (vertexCollapseChild==dataParent.vertex)
    {treeArrayChildIndex=j;};
    if (vertexCollapseParent==dataParent.vertex)
    {treeArrayParentIndex=j;};
    if (treeArrayChildIndex != -1 && treeArrayParentIndex != -1)
                        {break;}
    updateTreeArray(treeArrayChildIndex, treeArrayParentIndex,
                        treeArrayEmptyIndex, vertexCollapseChild,
    vertexCollapseParent);
              for (int j=0; j<10; j++) {                                               
                   System.out.println("\nIn-order:");
                   preOTrav(treeArray[j].getRoot());
         static void updateTreeArray(int c, int p, int e, int cc, int cp) {
                                  // c=treeArrayChildIndex
                                  // p=treeArrayParentIndex
                                  // e=treeArrayEmptyIndex
                                  // cc=vertexCollapseChild
                                  // cp=vertexCollapseParent
    System.out.println(c+" "+p+" "+e+" "+cc+" "+cp);
         if (c != -1) {
    if (p != -1) {
         dataParent = new treeNodeData();
              dataRight = (treeNodeData)treeArray[p].getData();
    dataParent.vertex=dataRight.vertex;
              nodeParent=new pTwoChildNode(dataParent);
    nodeParent.setLeft(treeArray[c].getRoot());
    nodeParent.setRight(treeArray[p].getRoot());
    treeArray[Math.min(c, p)].setRoot(nodeParent);
    treeArray[Math.max(c, p)].setRoot(null);
         else
              dataParent = new treeNodeData();
    dataParent.vertex=cp;
              nodeParent=new pTwoChildNode(dataParent);
    nodeParent.setLeft(treeArray[c].getRoot());
              dataRight = new treeNodeData();
    dataRight.vertex=cp;
              nodeParent.setRight(new pTwoChildNode(dataRight));
    treeArray[Math.min(c, e)].setRoot(nodeParent);
              treeArray[Math.max(c, e)].setRoot(null);
    else
    if (p != -1) {
    dataParent = new treeNodeData();
    dataRight = (treeNodeData)treeArray[p].getData();
    dataParent.vertex=dataRight.vertex;
              nodeParent=new pTwoChildNode(dataParent);
    dataLeft = new treeNodeData();
    dataLeft.vertex=cc;
    nodeParent.setLeft(new pTwoChildNode(dataLeft));
    nodeParent.setRight(treeArray[p].getRoot());
    treeArray[Math.min(p, e)].setRoot(nodeParent);
              treeArray[Math.max(p, e)].setRoot(null);
              else {
    dataParent=new treeNodeData();
    dataParent.vertex=cp;
              nodeParent=new pTwoChildNode(dataParent);
    dataRight=new treeNodeData();
    dataRight.vertex=cp;
              nodeRight=new pTwoChildNode(dataRight);
    nodeParent.setRight(nodeRight);
    dataLeft=new treeNodeData();
    dataLeft.vertex=cc;
              nodeLeft=new pTwoChildNode(dataLeft);
    nodeParent.setLeft(nodeLeft);
    treeArray[e].setRoot(nodeParent);
         static void preOTrav(pTwoChildNode n) {
              if (n == null)
              return;
              dataParent=(treeNodeData)n.getData();
              System.out.print(dataParent.vertex+" ");
              preOtrav(n.getLeft());
              preOtrav(n.getRight());
    //problems are here!!!!!
    class treeNodeData {
         int vertex;
         // data element2 -> a set of vertex fan;
    It doesn't compile but with the message saying that can not resolve the symbol in preOTrav(n.getLeft()); and preOTrav(n.getRight());
    Please help!

              preOtrav(n.getLeft());
              preOtrav(n.getRight());Don't write preOtrav when you mean preOTrav. Java is case-sensitive.
    Jesper

  • Can anyone advise on how to get a shopping cart on iweb please

    can anyone advise on how to get a shopping cart on iweb please

    I would suggest using Pay Pal. If you sign up for a free business account you can use the merchant services to set up buy now buttons, add to cart buttons, and the shopping cart. The only draw back is that your can't customize the look to match your site. I would use pay pal for two reasons, people know and trust them and its much cheaper than having your own merchant account. Good luck

  • Shopping cart does not load - help!

    i had several items in my shopping cart and after upgrading to a new laptop, i cannot access the cart at all! itunes tries to load and comes up blank. any thoughts?

    No error? Either way, if more than one computer is affected: contact iTMS Support via e-mail for a resolution.

  • Installation Problem Developer 6i/Oracle 8/Windows NT4 Please help.

    Hi,
    I am trying to install Oracle Developer 6i and Oracle 8
    under Windows NT platform. I had several kind of problem. Atlast
    I found the installation tips very help and followed it step by
    step. Still I am facing the problem. Let me explain what i did,
    step by step,
    1.downloaded the Oracle forms self extract file. Unzipped. Ran
    the Setup.exe.
    2.This prepared for Oracle Developer installation. I selected
    default path and home(d:\ORANT and home_Default). Selected
    oracle forms and installed it.
    3.Repeated step 2 to install reports 6i.
    4.Restarted the system.
    5.Created another directory d:\orantnew
    6.Used the Oracle 8 CD and installed using the Autorun.Selected
    different path and oracle Home this time.(D:\orantnew and
    home_New).
    7. Selected the Oracle Enterprise Edition option and did the
    installation.Rebooted the system.
    8. Did the TCP/IP changes explained in the Step (5) and Step (6)
    given below in Mr.Krishna's reply.
    9. Tried to start the listner by following Step (7) the listener
    won't start.
    10. Went ahead and copied the TNSNAMES.
    Connected to SQL*Plus using Start/Program/Oracle-OracntNew using
    SCOTT/TIGER and connect went thru.
    Then tried "CONNECT" from form builder, won't connect. I think
    the error message was some thing related to TNS..(Since I have
    uninstalled all the Oracle components now i can't give the exact
    error.Sorry). I would like to know if there is anything I am
    doing wrong or missing out something.
    Note : While uninstalling the oracle components i had problem
    removing the bin directory. So I had to stop some of the
    services
    (OracleServiceORC1 and OracleStartORC1 from
    start/controlpanel/services option) in order to delete the
    oracle components.
    Please someone let me know how can I install Oracle 8 and Oracle
    Developer 6i,in windows NT platform.
    Incase if i am doing anything wrong in the above given step or
    missing out something pl let me know.
    Thanks.
    Extracted from another thread
    Hi, >Try these steps, but you need to change a few things for Win2000 even I am trying, but Listener does'nt start there is a
    problem I am looking into it, If you find the solution pl let me
    know, these work fine on Win95/98 I have tried and they all work
    fine.>-------------------------------------------->Installing
    Personal Oracle 8. 1. 6. 0. 0 with Developer v6i (Reports 6. 0.
    8. 8. 3, Forms 6. 0. 8. 0. 9)>On Windows 98>Note: All other
    combinations may or may not work.> If you want to install
    designer as well, do it now.
    ** Clean all Oracles off the computer using the following instructions. (Windows 95 and
    Windows 98)
    1. In regedit, go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.
    2. Go to HKEY_CURRENT_USER\SOFTWARE\ORACLE
    3. Delete the ORACLE key.
    4. Delete HKEY_LOCAL_MACHINE\SOFTWARE\ODBC pertaining to Oracle.
    5. Delete HKEY_CURRENT_USER\SOFTWARE\ODBC pertaining to Oracle.
    6. Edit your AUTOEXE.BAT file and remove your %ORACLE_HOME%\bin and JRE paths from the path settings.
    7. From the Windows Explorer (or from the command prompt), delete the Oracle Directory
    (Oracle Base).
    8. Delete < System_Drive > C:\Program Files\Oracle (from the Windows NT Explorer or from the command
    prompt).
    9. Delete Icons from < System_Drive> C:\Windows\StartMenu\Programs\Oracle - <HOME> and <System_Drive>
    C:\Windows\StartMenu\Oracle Installation Products. Where<HOME>
    is the previous HOME name.
    10. Reboot the system.
    Installing Developer 6i(Forms and Reports)
    1. Download the file from OTN site or Install from the CD. Install the installer. It will go
    into a new default Oracle home that it will create. When you go
    to install your Developer CD, close the installer that comes up
    with the CD autorun. Go to the programs menu and Oracle for
    Windows 95 and click on the installer there. Once it is open,
    browse to the CD you wish to install. (installr/install/us)
    2. Start installer. Install Developer 6i first to default directory, Orawin95 How? Start installer, follow the prompts
    that appear on the screen, you may have to do this twice, once
    for Oracle Forms and once for Oracle Reports, after the
    installation is successful reboot the system.
    3. If you want to install Designer 6 as well, do it now. (But I have not installed
    the Designer ) Designer has to be installed before PO 8. 1. 6,
    because PO816 can detect only one Oracle_home.
    4. Create a new folder on your root directory called Orawin98. Start the installer set-up from where you downloaded it and
    select Orawin98 to install it in this time. You also need to
    give this second home a name whatever you want, but through out
    the process, you have to use the identical name, that is
    critical. Orawin98 indicates this name in these instructions. Do
    not reboot. Install Oracle 8.1.6 to the directory Orawin98 using
    the installer. Reboot the system.
    5. Go to Start/Setting/Control Panel/Network, if you do not have TCP/IP installed, install it
    now, if you do, highlight TCP/IP, click properties. Select DNS
    tab, select enable DNS, at the host area, type "Orawin98", leave
    domain empty. Go to Identification Tab and enter your database
    name, in this case BBM. Reboot the system after you finish.
    6. Configure your database listener. Go to Start/Programs/Oracle- Orawin98/Network Admistration/Net8
    Assistant, a window will pop
    up, at the window expand Local and expand Listeners and double
    click it, you will see a new window, go through all the tab
    menus. At location address 1, Host name: use "Orawin98", Port
    use: 1521 (default). And at location address 2, Host name:
    use "Orawin98", Port use: 2481, go to the file/ save, close Net8
    Assistant.
    7. Start listener how? Go to Dos Window, type LSNRCTL, return, at LSNRCTL>, type Start. Listener should start
    successfully, if not, you need to go back to Net8 Assistant to
    check configuration.
    8. Copy file "TNSNAMES" in directory C:\Orawin98\Net80\Admin to C:\oraein95\Net80\Admin.
    9. You are finished.
    10. To connect Forms/Reports/SQLPLUS to database - First start the
    Listener, then start the database. Next, go to File menu in
    Forms/Reports and select Connect. Type in user name and password
    (system/manager or whatever) in this case it is SCOTT/TIGER and
    the database name is your "DATABASENAME". When you want to quit
    you need to exit from file menu of Forms/Reports, then you need
    to stop Listener and then shut down database.
    11. You can rename your computer name in your original name. (for local networks)
    Let me know if it is working.>null

    Install Forms in one directory (You can have reports in the same
    directory).
    Install oracle DB in another directory.
    Don't change any file and reboot.
    The listener will start automatically as a service.
    (If not from a command line write "lsnrctl start" to start it).
    To connect from forms/report to the DB you need to activate the
    sqlnet easy config tool from the directory where forms is.
    Follow the wizard to define an entry in the tnsnames.ora file
    automatically.
    Then you can use your forms with the DB.
    (IF you get problems it usually helps to let us know the error
    code you get so we can direct you in the correct direction).

  • New to Java, Please help

    Hi, I was trying to play a game and came up with this java error (below), I uninstalled and reinstalled still no fix. I think i need a new class?, If anyone can explain the potential problem to me and help me fix it, that would be much appreciated. I'm a complete NEWB when it comes to java, I'm not even sure how to edit that code. so please remember to explain in the newbiest of newby answers. I am proficient with features of a computer just not java.
    Java Plug-in 1.6.0_24
    Using JRE version 1.6.0_24-b07 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Ethan
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    load: class loader.class not found.
    java.lang.ClassNotFoundException: loader.class
    at sun.plugin2.applet.Applet2ClassLoader.fi… Source)
    at sun.plugin2.applet.Plugin2ClassLoader.lo… Source)
    at sun.plugin2.applet.Plugin2ClassLoader.lo… Source)
    at sun.plugin2.applet.Plugin2ClassLoader.lo… Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.lo… Source)
    at sun.plugin2.applet.Plugin2Manager.create… Source)
    at sun.plugin2.applet.Plugin2Manager$Applet… Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassNotFoundException: loader.class

    845681 wrote:
    Hi, I was trying to play a game and came up with this java error (below), I uninstalled and reinstalled still no fix. I think i need a new class?, If anyone can explain the potential problem to me and help me fix it, that would be much appreciated. I'm a complete NEWB when it comes to java, I'm not even sure how to edit that code. so please remember to explain in the newbiest of newby answers. I am proficient with features of a computer just not java.If you want to learn how to program java, which is not the same as playing that particular game then you can start with the following link.
    http://download.oracle.com/javase/tutorial/getStarted/index.html

Maybe you are looking for