Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SOS...

0 views
Skip to first unread message

mak

unread,
May 3, 2007, 4:35:10 AM5/3/07
to
Hi ,how are you , may i hava your help to an application in java?The
program prints the information of the employees , salary,
rate ,name...The main program called BasePlusCommissionEmployeeTest3
is:
public class BasePlusCommissionEmployeeTest3{
public static void main(String[] args){
BasePlusCommissionEmployee3 basePlusCommissionEmployee =new
BasePlusCommissionEmployee3("Bob","Lewis","333-33-3333",5000,.04,300);
System.out.println("ergates\n");
System.out.printf("%s %s\n","first
name=",basePlusCommissionEmployee.getFirstName());
System.out.printf("%s %s
\n","lastName",basePlusCommissionEmployee.getLastName());
System.out.printf("%s %s
\n","ssn=",basePlusCommissionEmployee.getSocialSecurityNumber());
System.out.printf("%s %.2f\n","gross
sales=",basePlusCommissionEmployee.getGrossSales());
System.out.printf("%s %.2f\n","com
rate=",basePlusCommissionEmployee.getCommissionRate());
System.out.printf("%s %.2f
\n",basePlusCommissionEmployee.getBaseSalary());
basePlusCommissionEmployee.setBaseSalary(1000);
System.out.printf("\n%s: \n\n%s\n","o
ergaths:",basePlusCommissionEmployee.toString());
}
}
and calls class BasePlusCommissionEmployee3:
public class BasePlusCommissionEmployee3 extends COMEMP{
private double baseSalary;
public BasePlusCommissionEmployee3(String first,String last,String
ssn,double sales,double rate ,double salary){
super(first,last,ssn,sales,rate);
setBaseSalary(salary);
}
public void setBaseSalary(double salary){
baseSalary=(salary<0.0)?0.0:salary;

}
public double getBaseSalary(){
return baseSalary;
}
public double earnings(){
return baseSalary+(commissionRate*grossSales);
}
public String toString(){
return String.format("%s: %s %s/n%s: %s\n%s: %.2f\n%s: %.2f\n%s: %.
2f","o ergazomenos:",firstName,lastName,
"ssn=",socialSecurityNumber,"grossSales",grossSales,"commissionRate",
commissionRate,"base salary",baseSalary);

}
}
that calls class COMEMP: public class COMEMP{
protected String firstName;
protected String lastName;
protected String socialSecurityNumber;
protected double grossSales;
protected double commissionRate;
public COMEMP(String first,String last,String ssn,double
sales ,double rate){
firstName=first;
lastName=last;
socialSecurityNumber=ssn;
setGrossSales(sales);
setCommissionRate(rate);

}
public void setFirstName(String first){
firstName=first;
}
public String getFirstName(){
return firstName;
}
public void setLastName(String last){
lastName=last;
}
public String getLastName(){
return lastName;
}
public void setSocialSecurityNumber(String ssn){
socialSecurityNumber=ssn;
}
public String getSocialSecurityNumber(){
return socialSecurityNumber;
}
public void setGrossSales(double sales){
grossSales=(sales<0.0)?0.0:sales;
}
public double getGrossSales(){
return grossSales;
}
public void setCommissionRate(double rate){
commissionRate=(rate>0.0&&rate<1.0)?rate:0.0;
}
public double getCommissionRate(){
return commissionRate;
}
public double earnings(){
return commissionRate*grossSales;
}
public String toString(){
return String.format("%s: %s %s\n%s: %s\nn%s: %.2f\n%s: %.2f
","commission
employee",firstName,lastName,"ssn",socialSecurityNumber,"gross
sales",grossSales,"rate",commissionRate);
}
}
Compilation is successfully but runtime error says:

Bjorn Abelli

unread,
May 3, 2007, 9:52:04 AM5/3/07
to

"mak" <kert...@yahoo.gr> wrote...

> Hi ,how are you , may i hava your help to an application in java?The
> program prints the information of the employees , salary,
> rate ,name...

[snipped code]

> Compilation is successfully but runtime error says:

Well, what did it say? Forgot to paste it perhaps?

Anyway, the error when you run it gives a BIG clue:

Exception in thread "main" java.util.MissingFormatArgumentException:
Format specifier '.2f'
at java.util.Formatter.format(Formatter.java:2429)
at java.io.PrintStream.format(PrintStream.java:914)
at java.io.PrintStream.printf(PrintStream.java:815)
at
BasePlusCommissionEmployeeTest3.main(BasePlusCommissionEmployeeTest3.java:11)

Looking at the line in the stacktrace where *your* code appears, suggest
that there's something wrong at line 11 in
"BasePlusCommissionEmployeeTest3.java".

That line is:

System.out.printf("%s %.2f\n",

basePlusCommissionEmployee.getBaseSalary());

So what does the error say about that line:

MissingFormatArgumentException:
Format specifier '.2f'

.2f is the second format argument in your format string,
but how many arguments do you really have?


/// Bjorn A

a24...@googlemail.com

unread,
May 4, 2007, 3:45:57 AM5/4/07
to
On May 3, 10:35 am, mak <kertsa...@yahoo.gr> wrote:
> Hi ,how are you , may i hava your help to an application in java?

No. Learn to write meaningful subject lines. Learn to include the full
error message. Learn to provide useful example code.

TideRider

unread,
May 5, 2007, 10:43:00 AM5/5/07
to
<a24...@googlemail.com> wrote in message news:1178264757....@y80g2000hsf.googlegroups.com...

Someone seems to be in a crappy mood.

You are, of course, correct in the points you are making.

A clearer subject line will help draw someone with the right knowledge to the message.

The actual error message will help an experienced Java programmer pinpoint the
immediate problem, although it may not be the only problem.

The code tells all. Without the relevant code, we can only make guesses about the
problem.

Here's a real challenge, though. You know Java, and enjoy solving tough coding
problems. But can you guide someone to learn how to ask the right questions to
solve their own problems?

Or is it just more satisfying to rap a ruler across someone's knuckles?

You can always ignore a post that doesn't give enough information. Maybe someone else
will have the patience to guide the poster to a solution. Maybe not.


--
TideRider

0 new messages