Skip to content

Instantly share code, notes, and snippets.

@danicunhac
Created March 25, 2019 20:29
Show Gist options
  • Save danicunhac/c8ae58d8777aad420d3acdf4c0362ab7 to your computer and use it in GitHub Desktop.
Save danicunhac/c8ae58d8777aad420d3acdf4c0362ab7 to your computer and use it in GitHub Desktop.
Calculo da Area
public class Aplicacao {
public static void main(String[] args) {
double area;
Triangulo tri = new Triangulo();
tri.b = 5;
tri.h = 3;
area = tri.calcularArea();
System.out.println("Area do triangulo: " + area);
Quadrado q = new Quadrado();
q.l = 4;
area = q.calcularArea();
System.out.println("Area do quadrado: " + area);
Circunferencia c = new Circunferencia();
c.r = 3;
area = c.calcularArea();
System.out.println("Area da circunferencia: " + area);
Trapezio tra = new Trapezio();
tra.B = 7;
tra.b = 4;
tra.h = 5;
area = tra.calcularArea();
System.out.println("Area do trapezio: " + area);
}
}
public class Circunferencia {
double r;
double calcularArea() {
double area = (r*r)*Math.PI;
return area;
}
}
public class Quadrado {
double l;
double calcularArea() {
double area = l*l;
return area;
}
}
public class Trapezio {
double B;
double b;
double h;
double calcularArea() {
double area = ((B+b)*h)/2;
return area;
}
}
public class Triangulo {
double b;
double h;
double calcularArea() {
double area = b*h/2;
return area;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment