Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Sunday 15 May 2016

java program : Implementing all the basic methods in one program

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();
String name=new String("Welcome\t");
System.out.println(name.concat(s2));
System.out.println("\n");
}
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();

}
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;
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)
{
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);
}
}
}

No comments:

Post a Comment