my code didnt perform its function
i wrote a simple code which compiled but failed to actually work
this is wat it looks like
Code java:
// This is a simple code that code that adds x + y = z using the values x =4, y = 2
class Arithmetic {
int x;
short y;
int z;
/*Do the computations*/
public static void main(String args[]) {
int x = 4;
int y = 2;
int z = x + y;//compute z
/* use integer values in place of x and y*/
System.out.println("z = x + y");
System.out.println("The value of z");
}
}
pls i need help my first write up on my own and its given me concerns
Re: my code didnt perform its function
Please define what you mean by works...this could be quite a few things. My first guess is that you want it to print z?
Re: my code didnt perform its function
wat i meant by it didnt work is dat it was supposed to add the values the of x and y and print it as a new value for z
Re: my code didnt perform its function
Please do not start a second thread that asks the exact same question you just posted in this thread...I have removed your other post.
Next, see my post above. Printing things between quotes treats the value as a string...if you wish to print the actual value, send System.out.println() the actual value
Code java:
System.out.println("z");//print the string 'z'
System.out.println(z);//prints the value of z
Re: my code didnt perform its function
Quote:
wat i meant by it didnt work is dat
Recommended reading:
How To Ask Questions The Smart Way
db
Re: my code didnt perform its function
thanks for d info i have actually solved d problem