Que 1. arithmetic
class
arithmatic
{
public static void main(String args[])
{
int a=10;
int b=5;
// addition
int c=a+b;
System.out.println("sum is :"+c);
//subtract
int d=a-b;
System.out.println("subtract is :"+d);
//multiply
int e=a*b;
System.out.println("multiply is :"+e);
//divide
int f=a/b;
System.out.println("divide is :"+f);
}
output
sum is :15
subtract is :5
multiply is :50
divide is :2
Que 2 area of square
ans
class square
{
public static void
main(String args[])
{
int a=5;
int c=a*a;
System.out.println("the area of square is :"+c);
}
}
output
the area of square is :25
Que 3 area of triangle
ans
class triangle
{
public static void
main (String args[])
{
int h=10;
int b=5;
double
c=0.5*h*b;
System.out.println("the are of triangle is:"+c);
}
}
output
the are of ractangle is:25.0
Que 4 area of ractangle
ans
class ractangle
{
public static void
main (String args[])
{
int l=10;
int b=10;
int c=l*b;
System.out.println("the are of ractangle is:"+c);
}
}
output
the are of ractangle is: 100
Que 5 area of circle
ans
class circle
{
public static void main(String args[])
{
double a=3.14 ;
int r=3 ;
double c=a*r*r ;
System.out.println("The area of circle :"+c) ;
}
}
output
The area of circle :28.259999999999998
Que 6 swap two no.
ans
public class swap
{
public static void
main(String args[])
{
int a=10;
int b=5;
System.out.println("\nBefore swaping \n");
System.out.print("a="+a);
System.out.print("\nb="+b);
int c=a;
a=b;
b=c;
System.out.println("\n \nAfter swaping \n");
System.out.print("a="+a);
System.out.print("\nb="+b);
}
}
output
Before swaping
a=10
b=5
After swaping
a=5
b=10
Que 7. wap to add two no. using command line argument
output
the sum is 33
Que 8. wap to calculate area of circle using comm. line args?
Output
the area of Circle is :78.4
Que 9. wap to calculate area of Rectangle Using command line args?
Output
the area of Rectangle is: 30
Que 10. Wap to Check whether number is even or odd.
Output
number is even
Que. 11 write a program to use final variable.
output
error: cannot assign a value to final variable a
Que. 12 write a program to calculate area of circle using method (function)
output
input 5
Area of the circle is 78.5
0 Comments
"Thank you for your message! I appreciate your prompt response and the information you've provided. If you have any further details or if there's anything else I should know, please feel free to let me know. Looking forward to our continued communication!" -- Peaknotes.in