• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

In need of help urgently please!!

NOBEL

Member
The code below has one error, mind you I am not good at programming, so it is very frustrating sitting in front of the PC for 1.5 hours and can't get anything done.

Here is the error message
'class' or 'interface' expected
public void payday()


It would really help if some one could help me out (this is part of the full code, the full code is attached)





public class Staff
{
private StaffMember[] sMember;
public Staff()
{
sMember=new StaffMember[2];

Hourly t1= new Hourly ("Sam","123 Main Line","555-4569","425-652-124",9.5,0);
sMember[0]=t1;

Employee e =new Employee("Carla","456 Main Line","555-0789","123-456-786",6.5);
sMember[1]=e;

Hourly t2= new Hourly("Rob","998 Main Line","567-7754","542-326-586",8.55,2.0);
sMember[2]=t2;
}

}

public void payday()
{
double amount =0.0;
for (int i=0; i<3;i++)
{
System.out.println(sMember);
amount=sMember.pay();
if(amount==0)
System.out.println("Thanks \n");
else
System.out.println("Paid: "+amount+"\n");
System.out.println("---------------------------------------------------");
}
}
 
Looks like your braces are messed up so Public Void Payday() is defined outside of the class definition.

Try this instead:


public class Staff
{
private StaffMember[] sMember;
public Staff()
{
sMember=new StaffMember[2];

Hourly t1= new Hourly ("Sam","123 Main Line","555-4569","425-652-124",9.5,0);
sMember[0]=t1;

Employee e =new Employee("Carla","456 Main Line","555-0789","123-456-786",6.5);
sMember[1]=e;

Hourly t2= new Hourly("Rob","998 Main Line","567-7754","542-326-586",8.55,2.0);
sMember[2]=t2;
}

public void payday()
{
double amount =0.0;
for (int i=0; i<3;i++)
{
System.out.println(sMember);
amount=sMember.pay();
if(amount==0)
System.out.println("Thanks \n");
else
System.out.println("Paid: "+amount+"\n");
System.out.println("---------------------------------------------------");
}
}
}


EDIT: If that turns out to be the problem, don't feel bad. I spent almost an hour last night trying to figure out why my C++ code was throwing like 22 compile errors. Turns out I accidentally typed a closing brace instead of an opening brace. Somehow my eye never caught it.
 
Jeez, you guys need to learn to use some decent IDEs that tell you your syntax errors before you compile.
 
I'm using Visual Studio 6.0 for my C++ class. Any suggestions on better ones?
I started with Dev C++ but one of the assignments required stopping at various stages of the compiling and linking process and looking at the output. Apparently, Dev C++ can't do that.
 
Back
Top