0% found this document useful (0 votes)
2 views2 pages

JPR Manual Answers Experiment 2

The document contains Java code examples that evaluate different types of mathematical expressions. It includes three classes: Ex1, Expression, and Ex, each demonstrating various arithmetic operations and their outputs. The examples illustrate the use of addition, subtraction, multiplication, and division with integer variables.

Uploaded by

Riya Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

JPR Manual Answers Experiment 2

The document contains Java code examples that evaluate different types of mathematical expressions. It includes three classes: Ex1, Expression, and Ex, each demonstrating various arithmetic operations and their outputs. The examples illustrate the use of addition, subtraction, multiplication, and division with integer variables.

Uploaded by

Riya Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No:-2

 Write programs to evaluate different types of expressions.


Code:
class Ex1
{
public static void main(String args[])
{
int a=2,b=3,c=4,d=5,e=6,x;
x=a+b-c*d+e;
System.out.println("Value of x is:"+x);
}
}
Output:

Code:
class Expression
{
public static void main(String args[])
{
int a=2,b=3,c=6,d=1,e=2,f=10;
int y;

y=a+b+c-d/e*f;
System.out.println("Value of y is:"+y);
}
}
Output:
Code:
class Ex
{
public static void main(String args[])
{
int a=20,b=4;
int sum,sub,mul,div;
sum=a+b;
System.out.println("addition is: "+sum);
sub=a-b;
System.out.println("substraction is: "+sub);
mul=a*b;
System.out.println("multiplication is: "+mul);
div=a/b;
System.out.println("division is: "+div);
}
}
Ouput:

You might also like