💻 Hacer un programa que muestre el área y perímetro de un rectángulo.
ÁREA DEL RECTÁNGULO : AREA = b * h
PERÍMETRO DEL RECTÁNGULO : PERÍMETRO = (2*b) + (2*h)
ÁREA DEL RECTÁNGULO : Base x Altura (b*h)
• Perímetro de un rectángulo :
PERÍMETRO DEL RECTÁNGULO : (Base x 2) + (Altura x 2)
Algoritmo programacion_work
Definir P, A, b, h como Real;
Escribir "ÁREA DEL RECTÁNGULO";
Escribir Sin Saltar "BASE : ";
Leer b;
Escribir Sin Saltar "ALTURA : ";
Leer h;
A <- b * h;
Escribir "ÁREA : ",A,"cm.";
Escribir "";
Escribir "PERÍMETRO DEL RECTÁNGULO";
P <- (2 * h) + (2 * b);
Escribir "PERÍMETRO : ",P,"cm.";
FinAlgoritmo
print("18. ÁREA Y PERÍMETRO DEL RECTÁNGULO.")
import math
print("ÁREA DEL RECTÁNGULO")
b = int(input("INGRESE BASE : "))
h = int(input("INGRESE ALTURA : "))
A = b * h
print("ÁREA : ", round(A,2))
print()
print("PERÍMETRO DEL RECTÁNGULO")
P = (2 * h) + (2 * b)
print("PERÍMETRO : ",round(P,2))
#include<stdio.h>
int main() {
float b, h, A=0, P=0;
printf("18. AREA Y PERIMETRO DEL RECTANGULO\n\n");
printf("Ingrese Base : ");
scanf("%f",&b);
printf("Ingrese Altura : ");
scanf("%f",&h);
A = (b * h);
P = ( (2 * h) + (2 * b) );
printf("\nAREA : %.2f cm. \n",A);
printf("PERIMETRO : %.2f cm. \n",P);
return 0;
}
#include<iostream>
using namespace std;
int main() {
float b, h, A=0, P=0;
cout << "18. AREA Y PERIMETRO DEL RECTANGULO.\n\n";
cout << "Ingrese Base : ";
cin >> b;
cout << "Ingrese Altura : ";
cin >> h;
A = (b * h);
P = ( (2 * h) + (2 * b) );
cout << "AREA : " << A << "cm." << endl;
cout << "PERIMETRO : " << P << "cm." << endl;
return 0;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
class rectangulo
{
static void Main(string[] args)
{
double b, h, A = 0, P = 0;
Console.WriteLine("18. AREA Y PERIMETRO DEL RECTANGULO EN C#.\n");
Console.Write("Ingrese Base : ");
b = double.Parse(Console.ReadLine());
Console.Write("Ingrese Altura : ");
h = double.Parse(Console.ReadLine());
A = (b * h);
P = ((2 * h) + (2 * b));
Console.WriteLine("\nAREA : " + String.Format("{0,4:##.00}", A));
Console.WriteLine("PERIMETRO : " + String.Format("{0,4:##.00}", P));
Console.ReadLine();
}
}
}
package programacion_work;
import java.util.Scanner;
public class rectangulo {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
double A=0, P=0, b, h;
System.out.print("18. RECTÁNGULO - Mostrar el área y perímetro.\n\n");
System.out.print("INGRESE BASE : ");
b = Double.parseDouble(ingreso.next());
System.out.print("INGRESE ALTURA : ");
h = Double.parseDouble(ingreso.next());
A = b * h;
System.out.println("");
System.out.println("ÁREA : " + A + " cm.");
P = (2 * h) + (2 * b);
System.out.println("PERÍMETRO : " + P + " cm.");
}
}
private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {
double A=0, b, h;
b = Double.parseDouble(jTxt_Base.getText());
h = Double.parseDouble(jTxt_Altura.getText());
A = b * h;
jTxt_Area.setText(String.valueOf(A));
}
private void jBtn_Calcular1ActionPerformed(java.awt.event.ActionEvent evt) {
double P=0, b, h;
b = Double.parseDouble(jTxt_Base1.getText());
h = Double.parseDouble(jTxt_Altura1.getText());
P = (2 * h) + (2 * b);
jTxt_Perimetro.setText(String.valueOf(P));
}
Imports System.Console
Module rectangulo
Dim P, A, b, h As Decimal
Sub Main()
WriteLine("18. MOSTRAR EL ÁREA Y PERÍMETRO DE UN RECTÁNGULO.")
WriteLine("")
Write("Ingrese Base : ")
b = ReadLine()
Write("Ingrese Altura : ")
h = ReadLine()
A = b * h
P = (2 * h) + (2 * b)
WriteLine("")
WriteLine("ÁREA : " & A)
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, h As Decimal
b = Txt_Base.Text
h = Txt_Altura.Text
A = b * h
Txt_Area.Text = A
End Sub
Private Sub Btn_Calcular1_Click(sender As Object, e As EventArgs) Handles Btn_Calcular1.Click
Dim P, b, h As Decimal
b = Txt_Base1.Text
h = Txt_Altura1.Text
P = (2 * h) + (2 * b)
Txt_Perimetro.Text = P
End Sub
Sub Area_Rectangulo()
Dim b As Double
Dim h As Double
b = Range("C15").Value
h = Range("D15").Value
Range("G15").Value = (b * h)
End Sub
Sub Perimetro_Rectangulo()
Dim b As Double
Dim h As Double
b = Range("C18").Value
h = Range("D18").Value
Range("G18").Value = (2 * h) + (2 * b)
End Sub
Sub Area_Rectangulo2()
Dim b As Double
Dim h As Double
b = InputBox("INGRESE BASE ")
h = InputBox("INGRESE ALTURA ")
MsgBox "Área del Rectángulo : " & (b * h)
End Sub
Sub Perimetro_Rectangulo2()
Dim b As Double
Dim h As Double
b = InputBox("INGRESE BASE ")
h = InputBox("INGRESE ALTURA ")
MsgBox "Perímetro del Rectángulo : " & (2 * h) + (2 * b)
End Sub
Dim b As Double
Dim h As Double
Private Sub btn_area_Click()
b = txt_base1.Text
h = txt_altura1.Text
txt_area.Text = (b * h)
End Sub
Private Sub btn_perimetro_Click()
b = txt_base2.Text
h = txt_altura2.Text
txt_perimetro.Text = (2 * h) + (2 * b)
End Sub