Results 1 to 4 of 4
  1. #1
    jovin555 is offline Member
    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Default compilation error

    class PrintDetails()
    {
    public void printHeader(char c)
    {
    for(int counter=0;counter<70;counter++)
    {
    System.out.print(c);
    }
    }
    public void printHeader(char c,int no)
    {
    for(int counter=0;counter<no;counter++)
    {
    System.out.print(c);
    }
    }
    public void printHeader(String s)
    {
    System.out.println(s);
    }
    }

    class Purchase
    {
    private int billId;
    private float billAmount;

    public Purchase(int billId,float billAmount)
    {
    this.billId=billid;
    this.billAmount=billAmount;
    }
    public void calculateBill(String modeOfpayment,int processingCharge)
    {
    if(modeOfPayment.equalsIgnoreCase("Credit"))
    {
    billAmount=billAmount+(billAmount*processingCharge/100f);
    }
    }

    public void displayBill()
    {
    PrintDetails printobj = new PrintDetails();
    printobj.printHeader('-',80);
    printobj.printHeader("MORE Store Bill Details");
    printobj.printHeader('-', 80);
    System.out.println("");
    System.out.println("Bill Id :"+billId);
    System.out.println("Final bill to be paid : Rs."+billAmount);
    System.out.println("");
    printobj.printHeader('-',80);
    printobj.printHeader("THANKYOU VISIT AGAIN");
    printobj.printHeader('-', 80);
    }
    }


    class Retail
    {
    public static void main(String args[])
    {
    String modeOfPayment=args[0];
    int processingCharge=Integer.parseInt(args[1]);
    Purchase purobj=new Purchase(5001,1055.99f);
    purobj.calculateBill("Credit",5);
    purobj.displayBill();
    }
    }


    when i compile this code i get an error like this

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at Retail.main(Empdata.java:60)


    can anyone explain me whats wrong with my code???

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: compilation error

    It looks like you're trying to run this code from an IDE, as that's not actually a compiler error. What error do you get when you compile the program, not when you try to run it?

    Also, please use the code tags when posting code, which should be in the form of an SSCCE.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    jovin555 is offline Member
    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Default Re: compilation error

    i got it corrected.the reason was i ddnt give the command line arguements.in eclipse i ddnt know how to give that.Now i found out that.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: compilation error

    That doesn't really make sense. The error in your first post mentions a compilation error. That means your IDE was unable to compile your code, which means it wasn't able to run it. Command line arguments don't come into play until after the program is running.

    Chances are you fixed the compilation error without realizing it, and your command line arguments were a separate issue.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Compilation error
    By gnarkill10 in forum New To Java
    Replies: 2
    Last Post: 08-05-2012, 03:18 PM
  2. MIB compilation error - lexical error [0050]
    By ajuthani4@hotmail.com in forum Networking
    Replies: 0
    Last Post: 02-28-2012, 06:09 PM
  3. compilation error - pls help
    By codejava in forum New To Java
    Replies: 11
    Last Post: 09-27-2011, 09:14 AM
  4. Help with a compilation error
    By m_mccutcheon in forum New To Java
    Replies: 5
    Last Post: 08-15-2011, 05:20 PM
  5. compilation error
    By NoufalpRahman in forum Java Servlet
    Replies: 0
    Last Post: 04-26-2011, 08:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •