💻 Hacer un programa que muestre el área y perímetro de un trapecio.
ÁREA DEL TRAPECIO : ÁREA = ((B + b) * h) / 2
PERÍMETRO DEL TRAPECIO : PERÍMETRO = B + b + L1 + L2
Área de un trapecio :
Perímetro de un trapecio :
Algoritmo programacion_work
Definir P, A, B, Bb, h, l1, l2, l3, l4 como Real;
Escribir "ÁREA DEL TRAPECIO";
Escribir Sin Saltar "BASE MAYOR : ";
Leer B;
Escribir Sin Saltar "BASE MENOR : ";
Leer Bb;
Escribir Sin Saltar "ALTURA : ";
Leer h;
A <- ((B * Bb) * h ) / 2;
Escribir "ÁREA : ",A, " cm²";
Escribir "";
Escribir "PERÍMETRO DEL TRAPECIO";
Escribir Sin Saltar "LADO 01 : ";
Leer l1;
Escribir Sin Saltar "LADO 02 : ";
Leer l2;
Escribir Sin Saltar "LADO 03 : ";
Leer l3;
Escribir Sin Saltar "LADO 04 : ";
Leer l4;
P <- l1 + l2 + l3 + l4;
Escribir "PERÍMETRO : ",P, " cm";
FinAlgoritmo
print("23. ÁREA Y PERÍMETRO DEL TRAPECIO.")
import math
print("ÁREA DEL TRAPECIO")
B = float(input("BASE MAYOR : "))
Bb = float(input("BASE MENOR : "))
h = float(input("ALTURA : "))
A = ((B * Bb) * h ) / 2
print("ÁREA : ", round(A,2), "cm2")
print()
print("PERÍMETRO DEL TRAPECIO")
L1 = int(input("LADO 1 : "))
L2 = int(input("LADO 2 : "))
L3 = int(input("LADO 3 : "))
L4 = int(input("LADO 4 : "))
P = L1 + L2 + L3 + L4
print("PERÍMETRO : ",round(P,2), "cm")
#include<stdio.h>
int main() {
float B, Bb, h, l1, l2, l3, l4, A=0, P=0;
printf("23. AREA Y PERIMETRO DEL TRAPECIO.\n\n");
printf("Ingrese Base Mayor : ");
scanf("%f",&B);
printf("Ingrese Base Menor : ");
scanf("%f",&Bb);
printf("Ingrese Altura : ");
scanf("%f",&h);
A = ((B * Bb) * h ) / 2;
printf("AREA : %.2f cm. \n",A);
printf("\nIngrese Lado 01 : ");
scanf("%f",&l1);
printf("Ingrese Lado 02 : ");
scanf("%f",&l2);
printf("Ingrese Lado 03 : ");
scanf("%f",&l3);
printf("Ingrese Lado 04 : ");
scanf("%f",&l4);
P = l1 + l2 + l3 + l4;
printf("PERIMETRO : %.2f cm. \n", P);
return 0;
}
#include<iostream>
using namespace std;
int main() {
float B, Bb, h, l1, l2, l3, l4, A=0, P=0;
cout << "23. AREA Y PERIMETRO DEL TRAPECIO.\n\n";
cout << "Ingrese Base Mayor : ";
cin >> B;
cout << "Ingrese Base Menor : ";
cin >> Bb;
cout << "Ingrese Altura : ";
cin >> h;
A = ((B * Bb) * h ) / 2;
cout << "AREA : " << A << " cm." << endl;
cout << "\nIngrese Lado 01 : ";
cin >> l1;
cout << "Ingrese Lado 02 : ";
cin >> l2;
cout << "Ingrese Lado 03 : ";
cin >> l3;
cout << "Ingrese Lado 04 : ";
cin >> l4;
P = l1 + l2 + l3 + l4;
cout << "PERIMETRO : " << P << " cm." << endl;
return 0;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
class trapecio
{
static void Main(string[] args)
{
double B, Bb, h, l1, l2, l3, l4, A = 0, P = 0;
Console.WriteLine("23. AREA Y PERIMETRO DEL TRAPECIO EN C#.\n");
Console.Write("Ingrese Base Mayor : ");
B = double.Parse(Console.ReadLine());
Console.Write("Ingrese Base Menor : ");
Bb = double.Parse(Console.ReadLine());
Console.Write("Ingrese Altura : ");
h = double.Parse(Console.ReadLine());
A = ((B * Bb) * h) / 2;
Console.WriteLine("AREA : " + String.Format("{0,4:##.00}", A));
Console.Write("\nIngrese Lado 01 : ");
l1 = double.Parse(Console.ReadLine());
Console.Write("Ingrese Lado 02 : ");
l2 = double.Parse(Console.ReadLine());
Console.Write("Ingrese Lado 03 : ");
l3 = double.Parse(Console.ReadLine());
Console.Write("Ingrese Lado 04 : ");
l4 = double.Parse(Console.ReadLine());
P = l1 + l2 + l3 + l4;
Console.WriteLine("PERIMETRO : " + String.Format("{0,4:##.00}", P));
Console.ReadLine();
}
}
}
package programacion_work;
import java.util.Scanner;
public class trapecio {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
double P, A, B, Bb, h, l1, l2, l3, l4;
System.out.print("23. TRAPECIO - Mostrar el área y perímetro.\n\n");
System.out.print("INGRESE BASE MAYOR : ");
B = Double.parseDouble(ingreso.next());
System.out.print("INGRESE BASE MENOR : ");
Bb = Double.parseDouble(ingreso.next());
System.out.print("INGRESE ALTURA : ");
h = Double.parseDouble(ingreso.next());
A = ((B * Bb) * h) / 2;
System.out.println("ÁREA : " + A + " cm.");
System.out.println("");
System.out.print("INGRESE LADO 01 : ");
l1 = Double.parseDouble(ingreso.next());
System.out.print("INGRESE LADO 02 : ");
l2 = Double.parseDouble(ingreso.next());
System.out.print("INGRESE LADO 03 : ");
l3 = Double.parseDouble(ingreso.next());
System.out.print("INGRESE LADO 04 : ");
l4 = Double.parseDouble(ingreso.next());
P = l1 + l2 + l3 + l4;
System.out.println("PERÍMETRO : " + P + " cm.");
}
}
private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {
double A, B, Bb, h;
B = Double.parseDouble(jTxt_BaseMa.getText());
Bb = Double.parseDouble(jTxt_BaseMe.getText());
h = Double.parseDouble(jTxt_Altura.getText());
A = ((B * Bb) * h) / 2;
DecimalFormat df = new DecimalFormat("#.00");
jTxt_Area.setText(df.format(A));
}
private void jBtn_Calcular1ActionPerformed(java.awt.event.ActionEvent evt) {
double P, l1, l2, l3, l4;
l1 = Double.parseDouble(jTxt_Lado1.getText());
l2 = Double.parseDouble(jTxt_Lado2.getText());
l3 = Double.parseDouble(jTxt_Lado3.getText());
l4 = Double.parseDouble(jTxt_Lado4.getText());
P = l1 + l2 + l3 + l4;
DecimalFormat df = new DecimalFormat("#.00");
jTxt_Perimetro.setText(df.format(P));
}
Imports System.Console
Module trapecio
Dim P, A, B, Bb, h, l1, l2, l3, l4 As Decimal
Sub Main()
WriteLine("23. MOSTRAR EL ÁREA Y PERÍMETRO DE UN TRAPECIO.")
WriteLine("")
Write("Ingrese Base Mayor : ")
B = ReadLine()
Write("Ingrese Base Menor : ")
Bb = ReadLine()
Write("Ingrese Altura : ")
h = ReadLine()
A = ((B * Bb) * h) / 2
WriteLine("ÁREA : " & A)
WriteLine("")
Write("Ingrese Lado 01 : ")
l1 = ReadLine()
Write("Ingrese Lado 02 : ")
l2 = ReadLine()
Write("Ingrese Lado 03 : ")
l3 = ReadLine()
Write("Ingrese Lado 04 : ")
l4 = ReadLine()
P = l1 + l2 + l3 + l4
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, B, Bb, h As Decimal
B = Txt_BMay.Text
Bb = Txt_BMen.Text
h = Txt_Alt.Text
A = ((B * Bb) * h) / 2
Txt_Area.Text = A
End Sub
Private Sub Btn_Calcular1_Click(sender As Object, e As EventArgs) Handles Btn_Calcular1.Click
Dim P, l1, l2, l3, l4 As Decimal
l1 = Txt_Lado1.Text
l2 = Txt_Lado2.Text
l3 = Txt_Lado3.Text
l4 = Txt_Lado4.Text
P = l1 + l2 + l3 + l4
Txt_Perimetro.Text = P
End Sub
Sub Area_Trapecio()
Dim B As Double
Dim Bb As Double
Dim h As Double
B = Range("C15").Value
Bb = Range("D15").Value
h = Range("E15").Value
Range("H15").Value = ((B * Bb) * h) / 2
End Sub
Sub Perimetro_Trapecio()
Dim l1 As Double
Dim l2 As Double
Dim l3 As Double
Dim l4 As Double
l1 = Range("C18").Value
l2 = Range("D18").Value
l3 = Range("E18").Value
l4 = Range("F18").Value
Range("H18").Value = l1 + l2 + l3 + l4
End Sub
Sub Area_Trapecio2()
Dim B As Double
Dim Bb As Double
Dim h As Double
B = InputBox("INGRESE BASE MAYOR ")
Bb = InputBox("INGRESE BASE MENOR ")
h = InputBox("INGRESE ALTURA ")
MsgBox "Área del Trapecio : " & ((B * Bb) * h) / 2
End Sub
Sub Perimetro_Trapecio2()
Dim l1 As Double
Dim l2 As Double
Dim l3 As Double
Dim l4 As Double
l1 = InputBox("LADO 01 ")
l2 = InputBox("LADO 02 ")
l3 = InputBox("LADO 03 ")
l4 = InputBox("LADO 04 ")
MsgBox "Perímetro del Círculo : " & l1 + l2 + l3 + l4
End Sub
Dim B As Double
Dim Bb As Double
Dim h As Double
Dim l1 As Double
Dim l2 As Double
Dim l3 As Double
Dim l4 As Double
Private Sub btn_area_Click()
B = txt_BaseMa.Text
Bb = txt_BaseMe.Text
h = txt_Altura.Text
txt_area.Text = ((B * Bb) * h) / 2
End Sub
Private Sub btn_perimetro_Click()
l1 = txt_l1.Text
l2 = txt_l2.Text
l3 = txt_l3.Text
l4 = txt_l4.Text
txt_perimetro.Text = l1 + l2 + l3 + l4
End Sub