Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: program not compiling

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default program not compiling

    Hi the program below isn't compiling,the program compiles fine without the loop but when I incorporate the loop which is the last part of the program it is not compiling can you help me.

    import java.util.*;
    import java.text.*;
    class HardwareItems
    {
    String code;
    String description;
    double price;

    HardwareItems(String code,String description,double price){
    this.code=code;
    this.description=description;
    this.price=price;
    }
    public String getCode(){
    return code;
    }
    public String getDescription(){
    return description;
    }
    public double getPrice(){
    return price;
    }

    public static void main(String []args){
    Scanner in=new Scanner(System.in);
    double total=0;
    ArrayList<HardwareItems> list=new ArrayList<HardwareItems>();
    list.add(new HardwareItems("K16","Wood screws,brass,20mm",7.75));
    list.add(new HardwareItems("D24","Wood glue,clear,1 liter",5.50));
    list.add(new HardwareItems("M93","Sandpaper,fine grade",10.25));
    list.add(new HardwareItems("M94","Sandpaper,fine grade",14.75));
    DecimalFormat df=new DecimalFormat("$ ##.##");

    System.out.println("Hardware Items");
    System.out.println();
    System.out.println("Code "+" Description "+" Unit Price ");
    for(HardwareItems e : list){
    System.out.println(e.getCode()+"\t"+e.getDescripti on()+"\t"+df.format(e.getPrice()));
    }



    System.out.println("place your order!");
    System.out.print("NAME:");
    String l=in.next();
    System.out.print("ADDRESS-1:");
    String m=in.next();
    System.out.print("ADDRESS-2:");
    String n=in.next();
    System.out.print("ADDRESS-3:");
    String o=in.next();
    System.out.print("POST CODE:");
    String p=in.next();

    System.out.println("Enter Code (XX to stop)" );
    System.out.print("Code:" );
    String code=in.next();
    System.out.print("Quantity: ");
    int quantity=in.nextInt();
    while(!code.equals("XX")){
    System.out.print("Code:" );
    code=in.next();
    if(code.equals("XX")){
    break;
    }
    System.out.print("Quantity: ");
    quantity=in.nextInt();
    }
    }


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: program not compiling

    Close the code in code tags.

Similar Threads

  1. Compiling
    By yavo in forum Java Theory & Questions
    Replies: 1
    Last Post: December 24th, 2011, 07:42 AM
  2. Compiling error
    By tangara in forum Java IDEs
    Replies: 3
    Last Post: September 4th, 2011, 03:00 AM
  3. Compiling Error?
    By Arkeshen in forum Java Theory & Questions
    Replies: 2
    Last Post: June 22nd, 2011, 04:31 AM
  4. Help with Compiling
    By w.spidey in forum Object Oriented Programming
    Replies: 10
    Last Post: September 9th, 2010, 01:48 PM
  5. compiling a file
    By jkoracle23 in forum Java Theory & Questions
    Replies: 4
    Last Post: June 19th, 2010, 03:20 PM