Hi there,
I am new in java and some basic help would be appreciated. e.g

1-What's the out put of;

double number = (1/3)*3;
System.out.println("(1/3)*3 is equal to " + number);
What's missing?

2- Convert each of the following mathematical formula to java expression;

3x and 3x+y

Thank you in advance

1. 1/3 * 3 is equal to 1. Is that what your program is telling you?
2. Accept user input of numbers to represent x and y. Then apply them to the formulas.

double x, y, product, expression2;
product = 3*x;
expression2 = product + y;

Not sure if this is exactly what you are looking for. The original post was quite vague.

>>Hi there,
Hello there.

>>I am new in java and some basic help would be appreciated. e.g
Ok lets see...

>>1-What's the out put of;
>>double number = (1/3)*3;
>>System.out.println("(1/3)*3 is equal to " + number);
>>What's missing?
Did you try this out on a compiler ? Is this a H.W question ?
Here is a hint : in programming , 1/3 != 0.333...

>>2- Convert each of the following mathematical formula to java >>expression;

>>3x and 3x+y
More hints :
Declare a variable x ;
Declare a variable result1 and result2 and a variable y
For result1 make it equal to 3 time the variable x
For result2 make it equal to result1 plus 3

>>Thank you in advance
Hope that helped. Next time show some effort.

thanks guys, before I got my ordered 3rd addition java book, i have learned a lot from you.


Cheers M.Jama

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.