/*
WAP to calculate area of circle */
public class MyClass1 {
public static void main(String args[]) {
System.out.println("Enter the radius:");
double r=Double.parseDouble(args[0]);
double area= (22*r*r)/7;
System.out.println("area =" + area);
}
}
/*WAP to calculate circumference of circle */
public class MyClass2 {
public static void main(String args[]) {
System.out.println("Enter the radius:");
double r=Double.parseDouble(args[0]);
double cir= (22*2*r)/7;
System.out.println("cir= " + cir);
}
}
/*
WAP to swap given two strings */
public class MyClass3 {
public static void main(String args[]) {
String s1, s2,temp;
System.out.println("Enter both the strings :");
s1=args[0];
s2=args[1];
System.out.println("Strings before swapping s1="+s1+"s2="+s2);
temp=s1;
s1=s2;
s2=temp
System.out.println("Strings after swapping s1="+s1+"s2="+s2);
}
}
/*
WAP to convert temperature from
Fahrenheit to Celsius */
public class MyClass4 {
public static void main(String args[]) {
System.out.println("Enter the temperature in Fahrenheit :");
double f=Double.parseDouble(args[0]);
double temperature = ((f - 32)*5)/9;
System.out.println("Temperature in
Celsius = "
+ temperature);
}
}
/*WAP to find a square, square root, and Cube of a given no. using abstraction */
abstract class Myclass
{
abstract void calculate(double x);
}
class sub1 extends Myclass
{
void calculate (double x){
System.out.println("Square of ="+x*x);
}
}
class sub2 extends Myclass
{
void calculate (double x){
System.out.println("SquareRoot of ="+Math.sqrt(x));
}
}
class sub3 extends Myclass
{
void calculate (double x){
System.out.println("cube of ="+x*x*x);
}
}
class Test
{
public static void main(String[] args)
{
sub1 obj1= new sub1();
sub2 obj2= new sub2();
sub3 obj3= new sub3();
obj1.calculate(3);
obj2.calculate(4);
obj3.calculate(5);
System.out.println("Hello World!");
}
}
{
abstract void calculate(double x);
}
class sub1 extends Myclass
{
void calculate (double x){
System.out.println("Square of ="+x*x);
}
}
class sub2 extends Myclass
{
void calculate (double x){
System.out.println("SquareRoot of ="+Math.sqrt(x));
}
}
class sub3 extends Myclass
{
void calculate (double x){
System.out.println("cube of ="+x*x*x);
}
}
class Test
{
public static void main(String[] args)
{
sub1 obj1= new sub1();
sub2 obj2= new sub2();
sub3 obj3= new sub3();
obj1.calculate(3);
obj2.calculate(4);
obj3.calculate(5);
System.out.println("Hello World!");
}
}