Results 1 to 4 of 4
Thread: compilation error
- 01-31-2013, 04:06 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 6
- Rep Power
- 0
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???
- 01-31-2013, 04:09 PM #2
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!
- 01-31-2013, 04:35 PM #3
Member
- Join Date
- Jan 2013
- Posts
- 6
- Rep Power
- 0
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.
- 01-31-2013, 04:53 PM #4
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
-
Compilation error
By gnarkill10 in forum New To JavaReplies: 2Last Post: 08-05-2012, 03:18 PM -
MIB compilation error - lexical error [0050]
By ajuthani4@hotmail.com in forum NetworkingReplies: 0Last Post: 02-28-2012, 06:09 PM -
compilation error - pls help
By codejava in forum New To JavaReplies: 11Last Post: 09-27-2011, 09:14 AM -
Help with a compilation error
By m_mccutcheon in forum New To JavaReplies: 5Last Post: 08-15-2011, 05:20 PM -
compilation error
By NoufalpRahman in forum Java ServletReplies: 0Last Post: 04-26-2011, 08:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks