class Student
{
private int sid;
private String sname;
void setdata(int sid,String sname)
{
this.sid=sid;
this.sname=sname;
}
int getsid()
{
return sid;
}
String getsname()
{
return sname;
}
}
class Marks
{
private int sub1,sub2;
student std=new student();
void setdata(int sid,String sname,int s1,int s2)
{
std.setdata(sid,sname);
sub1=s1;
sub2=s2;
}
void findresult()
{
System.out.println("sid is"+std.getsid());
System.out.println("sname is"+std.getsname());
if (sub1<40 || sub2<40)
{
System.out.println("FAIL");
}
else
{
System.out.println("PASS");
}
}
}
class Test
{
public static void main(String[ ] args)
Marks m=new Marks();
m.setdata(10,"Anil",67,64);
m.findresult();
}
Ok, you seem to be missing an ending } for your class Test as you have closed the bracket for the main method but not the class.
Maybe that was a copying error.
You should really consider using constructors.
They're things that create the object.
For instance
public Student(nt sid,String sname)
{
this.sid=sid;
this.sname=sname;
}
rather than your set methods.
Also, and I can't say for certain on this as all you did was post code and not explain what was wrong, but I do see a possible issue
if (sub1<40 || sub2<40)
{
System.out.println("FAIL");
}
If you are intending that
both have to be at least 40, then you are doing it right.
If, however, you are intending that
at least one must be at least 40 in order to pass, then you are doing it wrong.
If you are intending that it be
at least one, then you should use && as that would make it so that
both have to be less than 40 to fail whereas with || you are making it so that
both have to be 40 or more in order to pass.