Nuevo documento de texto java

52
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
52
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Nuevo documento de texto java

  1. 1. package triangulo; import java.util.Scanner; public class Triangulo { private int base, altura, lado1, lado2, lado3; private float Area; private int Perimetro; public Triangulo() { Scanner teclado = new Scanner(System.in); System.out.println("Ingrese base del triángulo"); base = teclado.nextInt(); System.out.println("Ingrese altura del triángulo"); altura = teclado.nextInt(); System.out.println("Ingrese lado 1 triángulo"); lado1 = teclado.nextInt(); System.out.println("Ingrese lado 2 triángulo"); lado2 = teclado.nextInt(); } public void hallarArea() { Area = base*altura/2; System.out.println("El Area Es : "+Area); } public void hallarPerimetro() { Perimetro = base + lado1 + lado2; System.out.println("El perimetro es: " + Perimetro); } public static void main(String[] args) { // Triangulo objeto = new Triangulo(); // objeto.hallarPerimetro(); Triangulo objeto2 = new Triangulo(); objeto2.hallarArea(); } }

×