import java.util.*;
class Demo extends Thread
{
public void run()
{
System.out.println("Thread is running simuntaneously");
System.out.println("\n");
}
}
abstract class Shape
{
static String user;
void display()
{
System.out.println("The color of this shape is :");
}
void get()
{
Scanner s1=new Scanner(System.in);
System.out.println("Enter your name");
user=s1.next();
String s2=user.toUpperCase();
class Demo extends Thread
{
public void run()
{
System.out.println("Thread is running simuntaneously");
System.out.println("\n");
}
}
abstract class Shape
{
static String user;
void display()
{
System.out.println("The color of this shape is :");
}
void get()
{
Scanner s1=new Scanner(System.in);
System.out.println("Enter your name");
user=s1.next();
String s2=user.toUpperCase();
String name=new String("Welcome\t");
System.out.println(name.concat(s2));
System.out.println("\n");
System.out.println(name.concat(s2));
System.out.println("\n");
}
abstract void put();
}
class Hello extends Shape
{
void put()
{
System.out.println("Welcome user");
}
abstract void put();
}
class Hello extends Shape
{
void put()
{
System.out.println("Welcome user");
}
}
interface Calculate
{
void area();
}
class Rectangle extends Shape implements Calculate
{
int length,breadth;
Rectangle()
{
this.length=length;
this.breadth=breadth;
System.out.println("This is the rectangle details");
Scanner sr=new Scanner(System.in);
System.out.println("Enter the length of the rectangle");
length=sr.nextInt();
System.out.println("Enter the length of the rectangle");
breadth=sr.nextInt();
{
void area();
}
class Rectangle extends Shape implements Calculate
{
int length,breadth;
Rectangle()
{
this.length=length;
this.breadth=breadth;
System.out.println("This is the rectangle details");
Scanner sr=new Scanner(System.in);
System.out.println("Enter the length of the rectangle");
length=sr.nextInt();
System.out.println("Enter the length of the rectangle");
breadth=sr.nextInt();
}
public void area()
{
int ar=length*breadth;
System.out.println("The area of the rectangle is :"+ar);
}
void display()
{
super.display();
System.out.println("Red");
System.out.println("\n");
}
void put()
{
System.out.println("End of details");
}
}
class Triangle extends Shape implements Calculate
{
int length,breadth,height;
Triangle()
{
this.length=length;
this.breadth=breadth;
this.height=height;
System.out.println("This is the triangle details");
Scanner sr=new Scanner(System.in);
System.out.println("Enter the length of the triangle");
length=sr.nextInt();
System.out.println("Enter the breadth of the triangle");
breadth=sr.nextInt();
System.out.println("Enter the height of the Triangle");
height=sr.nextInt();
}
public void area()
{
int ar=length*breadth*height;
}
void display()
{
super.display();
System.out.println("Red");
System.out.println("\n");
}
void put()
{
System.out.println("End of details");
}
}
class Triangle extends Shape implements Calculate
{
int length,breadth,height;
Triangle()
{
this.length=length;
this.breadth=breadth;
this.height=height;
System.out.println("This is the triangle details");
Scanner sr=new Scanner(System.in);
System.out.println("Enter the length of the triangle");
length=sr.nextInt();
System.out.println("Enter the breadth of the triangle");
breadth=sr.nextInt();
System.out.println("Enter the height of the Triangle");
height=sr.nextInt();
}
public void area()
{
int ar=length*breadth*height;
System.out.println("The area of the triangle is :"+ar);
}
void display()
{
super.display();
System.out.println("Blue");
}
void put()
{
System.out.println("End of details");
}
}
class Demo32
{
public static void main(String st[])
{
try
{
Shape sh=new Hello();
sh.get();
int ch;
Scanner s=new Scanner(System.in);
System.out.println("Enter the choice 1.Triangle 2.Rectangle");
ch=s.nextInt();
switch(ch)
{
void display()
{
super.display();
System.out.println("Blue");
}
void put()
{
System.out.println("End of details");
}
}
class Demo32
{
public static void main(String st[])
{
try
{
Shape sh=new Hello();
sh.get();
int ch;
Scanner s=new Scanner(System.in);
System.out.println("Enter the choice 1.Triangle 2.Rectangle");
ch=s.nextInt();
switch(ch)
{
case 1:
{
Demo d=new Demo();
d.start();
Triangle tri=new Triangle();
tri.area();
tri.display();
tri.put();
break;
}
case 2:
{
Demo d1=new Demo();
d1.start();
Rectangle rect=new Rectangle();
rect.area();
rect.display();
rect.put();
break;
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
{
Demo d=new Demo();
d.start();
Triangle tri=new Triangle();
tri.area();
tri.display();
tri.put();
break;
}
case 2:
{
Demo d1=new Demo();
d1.start();
Rectangle rect=new Rectangle();
rect.area();
rect.display();
rect.put();
break;
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
No comments:
Post a Comment