public class Calculate
{
Calculate()
{
int x,y,sum, multiply,devide;
x=12;
y=5;
sum=x+y;
multiply=x*y;
devide=x/y;
}
public static void main(String[] args)
{
System.out.println("the sum of two numbers:" + sum);
System.out.println("the multiple of two numbers:" + multiply);
System.out.println("the devition of two numbers:" + divide);
}
}
mcmanuel20
0
Newbie Poster
Recommended Answers
Jump to PostYour class format is incorrect. When you create a class with main() method and you want to test the class out, you should have the class constructor. Then you can implement other methods. Before you start coding, this
Jump to Post@jalpesh, I'm not sure whether the compiler will allow line 4 to pass. It may throw illegal starting statement or something like that...
All 8 Replies
wen_cai
-3
Junior Poster in Training
Taywin
312
Posting Virtuoso
jalpesh_007
-3
Newbie Poster
Taywin
312
Posting Virtuoso
jalpesh_007
-3
Newbie Poster
mcmanuel20
0
Newbie Poster
Taywin
312
Posting Virtuoso
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
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.