💻 Hacer un programa que calcule el área y el perímetro de un pentágono.
ÁREA DEL PENTÁGONO : ÁREA = (P * ap)/2
PERÍMETRO DEL PENTÁGONO : PERÍMETRO = 5L
Área de un pentagono :
Perímetro de un pentágono :
Algoritmo programacion_work
// Área y Perímetro de un PENTÁGONO
Definir P, A, ap, l como Real;
Escribir "ÁREA DEL PENTÁGONO";
Escribir Sin Saltar "PERÍMETRO : ";
Leer P;
Escribir Sin Saltar "APOTEMA : ";
Leer ap;
A <- (P * ap)/2;
Escribir "ÁREA : ",A, "cm²";
Escribir "";
Escribir "PERÍMETRO DEL PENTÁGONO";
Escribir Sin Saltar "LADO : ";
Leer l;
P <- 5 * l;
Escribir "PERÍMETRO : ",P, "cm";
FinAlgoritmo
print("21. ÁREA Y PERÍMETRO DEL PENTÁGONO.")
import math
print("ÁREA DEL PENTÁGONO")
pe = float(input("PERÍMETRO : "))
ap = float(input("APOTEMA : "))
A = (pe * ap) / 2
print("ÁREA : ", round(A,2))
print()
print("PERÍMETRO DEL PENTÁGONO")
l = float(input("INGRESE LADO : "))
P = 5 * l
print("PERÍMETRO : ",round(P,2))
#include<stdio.h>
int main() {
float ap, l, A=0, P=0;
printf("21. AREA Y PERIMETRO DEL PETAGONO.\n\n");
printf("Ingrese Perimetro : ");
scanf("%f",&P);
printf("Ingrese Apotema : ");
scanf("%f",&ap);
A = (P * ap)/2;
printf("AREA : %.2f cm. \n",A);
printf("\nIngrese Lado : ");
scanf("%f",&l);
P = 5 * l;
printf("PERIMETRO : %.2f cm. \n", P);
return 0;
}
#include<iostream>
using namespace std;
int main() {
float ap, l, A=0, P=0;
cout << "21. AREA Y PERIMETRO DEL PETAGONO.\n\n";
cout << "Ingrese Perimetro : ";
cin >> P;
cout << "Ingrese Apotema : ";
cin >> ap;
A = (P * ap)/2;
cout << "AREA : " << A << " cm." << endl;
cout << "\nIngrese Lado : ";
cin >> l;
P = 5 * l;
cout << "PERIMETRO : " << P << " cm." << endl;
return 0;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
class pentagono
{
static void Main(string[] args)
{
double ap, l, A = 0, P = 0;
Console.WriteLine("21. AREA Y PERIMETRO DEL PETAGONO EN C#.\n");
Console.Write("Ingrese Perimetro : ");
P = double.Parse(Console.ReadLine());
Console.Write("Ingrese Apotema : ");
ap = double.Parse(Console.ReadLine());
A = (P * ap) / 2;
Console.WriteLine("AREA : " + String.Format("{0,4:##.00}", A));
Console.Write("\nIngrese Lado : ");
l = double.Parse(Console.ReadLine());
P = 5 * l;
Console.WriteLine("PERIMETRO : " + String.Format("{0,4:##.00}", P));
Console.ReadLine();
}
}
}
package programacion_work;
import java.util.Scanner;
public class pentagono {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
double pe, ap, A, L, P;
System.out.print("21. PENTÁGONO - Mostrar el área y perímetro.\n\n");
System.out.print("INGRESE PERÍMETRO : ");
pe = Double.parseDouble(ingreso.next());
System.out.print("INGRESE APOTEMA : ");
ap = Double.parseDouble(ingreso.next());
A = (pe * ap)/2;
System.out.println("ÁREA : " + A + " cm.");
System.out.println("");
System.out.print("INGRESE LADO : ");
L = Double.parseDouble(ingreso.next());
P = 5 * L;
System.out.println("PERÍMETRO : " + P + " cm.");
}
}
private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {
double pe, ap, A;
pe = Double.parseDouble(jTxt_P.getText());
ap = Double.parseDouble(jTxt_A.getText());
A = (pe * ap)/2;
DecimalFormat df = new DecimalFormat("#.00");
jTxt_Area.setText(df.format(A));
}
private void jBtn_Calcular1ActionPerformed(java.awt.event.ActionEvent evt) {
double L, P;
L = Double.parseDouble(jTxt_Lado.getText());
P = 5 * L;
DecimalFormat df = new DecimalFormat("#.00");
jTxt_Perimetro.setText(df.format(P));
}
Imports System.Console
Module circulo
Dim P, A, ap, l As Decimal
Sub Main()
WriteLine("21. MOSTRAR EL ÁREA Y PERÍMETRO DE UN PENTÁGONO.")
WriteLine("")
Write("Ingrese Perímetro : ")
P = ReadLine()
Write("Ingrese Apotema : ")
ap = ReadLine()
A = (P * ap) / 2
WriteLine("ÁREA : " & A)
WriteLine("")
Write("Ingrese Lado : ")
l = ReadLine()
P = 5 * l
WriteLine("PERÍMETRO : " & P)
ReadLine()
End Sub
End Module
Private Sub Btn_Calcular_Click(sender As Object, e As EventArgs) Handles Btn_Calcular.Click
Dim A, D, dd As Decimal
D = Txt_DMayor.Text
dd = Txt_DMenor.Text
A = (D * dd) / 2
Txt_Area.Text = A
End Sub
Private Sub Btn_Calcular1_Click(sender As Object, e As EventArgs) Handles Btn_Calcular1.Click
Dim P, l As Decimal
l = Txt_Lado.Text
P = 4 * l
Txt_Perimetro.Text = P
End Sub
Sub Area_Pentagono()
Dim P As Double
Dim ap As Double
P = Range("C15").Value
ap = Range("D15").Value
Range("G15").Value = (P * ap) / 2
End Sub
Sub Perimetro_Pentagono()
Dim l As Double
l = Range("D18").Value
Range("G18").Value = 5 * l
End Sub
Sub Area_Pentagono2()
Dim P As Double
Dim ap As Double
P = InputBox("PERÍMETRO ")
ap = InputBox("APOTEMA ")
MsgBox "Área del Pentágono : " & (P * ap) / 2
End Sub
Sub Perimetro_Pentagono2()
Dim l As Double
l = InputBox("INGRESE LADO ")
MsgBox "Perímetro del Pentágono : " & (5 * l)
End Sub
Dim P As Double
Dim ap As Double
Dim l As Double
Private Sub btn_area_Click()
P = txt_peri.Text
ap = txt_apot.Text
txt_area.Text = (P * ap) / 2
End Sub
Private Sub btn_perimetro_Click()
l = txt_Lado.Text
txt_perimetro.Text = 5 * l
End Sub