pls i need it today
we need more details. do you ask the user for the length of two or all of the sides?
please answer these if you want people that read this after me to be able to answer you.
Program to calculate the perimeter of a square, rectangle and triangle CLICK HERE! MORE INFORMATION! area parabolic simpson trpezoidal:: area perimeter square worksheets blackline area perimeter triangles area perimeter worksheet grade6 area petrolera cha ares herrados area phone codes http://freemindmedia.org/news/page.php?id=2219HOME |
public class Shape
{
private String shape;
private int perimeter;
public String m;
// constructors
public Shape()
{
setPerimeter();
setShape("point");
}
public Shape(int x)
{
setPerimeter(x);
setShape("Square");
}
public Shape(int x, int y)
{ FastGEO - By Arash Partow:: An implementation of the graham scan algorithm used in calculating the convex hull (or Optimizations made for segment to triangle, rectangle and quadix http://www.partow.net/projects/fastgeo/index.htmlHOME |
setPerimeter(x,y);
setShape("Rectangle");
}
public Shape(int x, int y, int z)
{
setPerimeter(x,y,z);
setShape("Triangle");
}
// method to set the name of the shape
public void setShape(String m)
{
shape = m;
}
// Methods to calculate the perimetre of the shapes
public void setPerimeter()
{
perimeter=0;
}
public void setPerimeter(int x)
{
perimeter=x*4;
}
public void setPerimeter(int x, int y)
{
perimeter=(x*2)+(y*2);
}
public void setPerimeter(int x , int y, int z)
{
perimeter = x+y+z;
}
// methods to return the values of the perimeters
public int getPerimeter()
{
return perimeter;
}
public String getShape()
{
return shape;
}
}// ends the class
Java Coding-http://codingjava.blogspot.com/
class TrianglePerimeter{
public static void main(String args){
if(args.length!=3){
System.out.println("Wrong number of arguments");
}else{
Double sideA = new Double(args[0]);
Double sideB= new Double(args[1]);
Double sideC = new Double(args[2]);
System.out.println(sideA + sideB + sideC);
}
}
}
Save as TrianglePerimeter.java
compile using javac TrianglePerimeter.java
run usinse java TrianglePerimeter 1 2 3
(where 1 2 3 are the lengths of your sides)
Pre-Article:Does University of Washington have any highly distinguished proffessors? Next-Article:A better way to layout complex image compositions (than tables) in HTML?
|