SysChat

SysChat (http://www.syschat.com/forum.php)
-   Development (http://www.syschat.com/software-support/development/)
-   -   Question please help me with this problem (http://www.syschat.com/please-help-me-with-this-problem-6077.html)

bsudhir6 09-20-2010 09:25 PM

please help me with this problem
 
Enc.java

package Obj5_1;

public class Enc
{
//Instance variables declared as private
private int x=6;
private char c='s';
private float f=5f;
//The accessor and mutator methods
public void setX(int val)
{
x=val;
}
public int getX()
{
return x;
}
public void setC(char val)
{
x=val;
}
public char getC()
{
return c;
}
public void setF (float val)
{
f=val;
}
public float getF()
{
return f;
}
}

class EncEx
{
public static void main(String[] args)
{
int i;
char j;
float k;
Enc E=new Enc();
System.out.println("The values of i,j,k before operation:");
i=44;
j='d';
k=43f;
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("k="+k);
System.out.println("The values of i,j,k after get operation:");
i=E.getX();
j=E.getC();
k=E.getF();
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("k="+k);
System.out.println("The values of x,c,f after set operation:");
E.setX(45);
E.setC('S');
E.setF(6.45f);
System.out.println("x="+E.getX());
System.out.println("c="+E.getC());
System.out.println("f="+E.getF());
}
}
Output:
The values of i,j,k before operation:
i=44
j=d
k=43.0
The values of i,j,k after get operation:
i=6
j=s
k=5.0
The values of x,c,f after set operation:
x=83
c=s
f=6.45

X value is supposed to be 45 not 83 please help me with this…


All times are GMT -4. The time now is 12:34 AM.


Copyright © 2005-2013 SysChat.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54