SysChat is a free online computer support community. Ask questions, share resources, contribute knowledge and discuss technology. Join our growing community to access all features. Register Now!

SysChat » Software Support » Development » Question please help me with this problem

Development

Support help and discuss software development and programming.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 09-20-2010, 09:25 PM
bsudhir6 bsudhir6 is offline
Junior Member
 
About:
Join Date: Dec 2009
Posts: 11
bsudhir6 is on a distinguished road

Exclamation 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…



Reply With Quote
Reply





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Steps Recorder in Windows 7 R2D2 Windows 7 0 05-07-2010 01:33 PM
Problem With Default wallpaper GPO bhanuk Operating Systems 0 10-15-2008 02:53 AM
Microsoft Outlook Has Encountered a Problem and Needs to Close Error in Outlook Andrew Watson Articles 0 04-22-2008 03:46 AM
Weird problem with net connection WarDoGG Networking 1 11-03-2007 12:45 PM
Dhcp leasing problem Kloppstock Networking 6 05-07-2007 09:25 AM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are on



» Ads



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