Categoría de Estructura Condicional Simple
💻 Hacer un programa que calcule el promedio de 3 notas, si el promedio es mayor de 10.5 mostrar aprobado, caso contrario mostrar desaprobado.
Para obtener el promedio se suman las notas y se divide entre la cantidad de notas; en nuestro caso nuestra evaluación es de 0 a 20; dónde de 0 a 10 es desaprobado y 11 a 20 es aprobado; por lo tanto, si la nota es mayor que 10 mostrará el mensaje de aprobado caso contrario desaprobado.
ANÁLISIS DEL CÓDIGO
Para obtener el promedio se suman las notas y se divide entre la cantidad de notas; en Perú la evaluacion es de 0 a 20; dónde de 0 a 10 es desaprobado y 11 a 20 es aprobado; por lo tanto, si la nota es mayor a 10 mostrará aprobado sino desaprobado.
VARIABLES ENTRADA :
N1, N2, N3 = Guardan las 3 notas ingresadas por teclado.
prom = Guarda el calculo del promedio de las 3 notas.
INGRESO : Se ingresan las notas
PROCESO : prom = (N1 + N2 + n3)/3
SALIDA : Muestra el promedio (prom).
Algoritmo programacion_work
Definir N1, N2, N3 como Entero;
Definir Prom como Real;
Escribir "MOSTRAR APROBADO Ó DESAPROBADO SEGÚN SU PROMEDIO.";
Escribir " ";
Escribir Sin Saltar "Ingrese Nota 01 : ";
Leer N1;
Escribir Sin Saltar "Ingrese Nota 02 : ";
Leer N2;
Escribir Sin Saltar "Ingrese Nota 03 : ";
Leer N3;
Prom <- (N1+N2+N3)/3;
Escribir " ";
Si Prom > 10.5 Entonces
Escribir "APROBADO CON ", Prom;
SiNo
Escribir "DESAPROBADO CON ", Prom;
FinSi
FinAlgoritmo
print("10. MOSTRAR APROBADO O DESAPROBADO.")
n1 = int(input("Ingrese Nota 01 : "))
n2 = int(input("Ingrese Nota 02 : "))
n3 = int(input("Ingrese Nota 03 : "))
prom = (n1+n2+n3)/3
if prom>10.5:
print("APROBADO : {:.2f}".format(prom))
else:
print("DESAPROBADO : {:.f2}".format(prom))
#include<stdio.h>
int main() {
float n1, n2, n3, prom;
printf("10. MOSTRAR EL PROMEDIO DE APROBADOS Y DESAPROBADOS.\n\n");
printf("Ingrese Nota 01 : ");
scanf("%f",&n1);
printf("Ingrese Nota 02 : ");
scanf("%f",&n2);
printf("Ingrese Nota 03 : ");
scanf("%f",&n3);
prom = (n1+n2+n3)/3;
if (prom > 10.5) {
printf("\nAPROBADO CON : %.2f\n",prom);
} else {
printf("DESAPROBADO CON : %.2f\n",prom);
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
float n1, n2, n3, prom;
const int nDec(4);
cout << "10. MOSTRAR EL PROMEDIO DE APROBADOS O DESAPROBADOS.\n\n";
cout << "Ingrese Nota 01 : ";
cin << n1;
cout << "Ingrese Nota 02 : ";
cin << n2;
cout << "Ingrese Nota 03 : ";
cin << n3;
prom = (n1+n2+n3)/3;
cout.precision(nDec);
cout << endl;
if (prom > 10.5) {
cout << "APROBADO CON : " << prom << endl;
}else {
cout << "DESAPROBADO CON : " << prom << endl;
return 0;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
class aprobado_desaprobado
{
static void Main(string[] args)
{
double n1, n2, n3, prom;
Console.WriteLine("10. MOSTRAR EL PROMEDIO DE APROBADOS O DESAPROBADOS.\n");
Console.Write("Ingrese Nota 01 : ");
n1 = double.Parse(Console.ReadLine());
Console.Write("Ingrese Nota 02 : ");
n2 = double.Parse(Console.ReadLine());
Console.Write("Ingrese Nota 03 : ");
n3 = double.Parse(Console.ReadLine());
prom = (n1 + n2 + n3) / 3;
if (prom > 10.5)
{
Console.WriteLine("\nAPROBADO CON : " + String.Format("{0,6:##.00}", prom));
}
else
{
Console.WriteLine("\nDESAPROBADO CON : " + String.Format("{0,6:##.00}", prom));
}
Console.ReadLine();
}
}
}
package programacion_work;
import java.util.Scanner;
public class aprobado_desaprobado {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
double prom, n1, n2, n3;
System.out.print("10. MOSTRAR SI ESTÁ APROBADO O DESAPROBADO.\n\n");
System.out.print("Ingrese Nota 1 :");
n1 = Double.parseDouble(ingreso.next());
System.out.print("Ingrese Nota 2 :");
n2 = Double.parseDouble(ingreso.next());
System.out.print("Ingrese Nota 3 :");
n3 = Double.parseDouble(ingreso.next());
prom = (n1 + n2 + n3)/3;
if(prom >= 10.5){
System.out.println("APROBADO CON : " + prom);
}else{
System.out.println("DESAPROBADO SON : " + prom);
}
}
}
package programacion_work;
import java.text.DecimalFormat;
private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {
double prom, n1, n2, n3;
DecimalFormat df = new DecimalFormat("#.00");
n1 = Double.parseDouble(jTxt_num1.getText());
n2 = Double.parseDouble(jTxt_num2.getText());
n3 = Double.parseDouble(jTxt_num3.getText());
prom = (n1 + n2 + n3)/3;
if(prom >= 10.5){
jLabel5.setText("APROBADO");
jTxt_Prom.setText(df.format(prom));
}else{
jLabel5.setText("DESAPROBADO");
jTxt_Prom.setText(df.format(prom));
}
}
Imports System.Console
Module aprobado_o_desaprobado
Dim Prom, N1, N2, N3 As Decimal
Sub Main()
WriteLine("10. MOSTRAR SI ESTÁ APROBADO O DESAPROBADO.")
WriteLine("")
Write("Ingrese Nota 1 : ")
N1 = ReadLine()
Write("Ingrese Nota 2 : ")
N2 = ReadLine()
Write("Ingrese Nota 3 : ")
N3 = ReadLine()
WriteLine("")
Prom = (N1 + N2 + N3) / 3
If (PROM > 10.5) Then
WriteLine("APROBADO CON - " & Prom)
Else
WriteLine("DESAPROBADO CON - " & Prom)
End If
ReadLine()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Prom, N1, N2, N3 As Decimal
N1 = Txt_Nota1.Text
N2 = Txt_Nota2.Text
N3 = Txt_Nota3.Text
Prom = (N1 + N2 + N3) / 3
If Prom >= 10.5 Then
Label5.Text = "APROBADO CON"
Txt_Prom.Text = Math.Round(Prom, 2)
Else
Label5.Text = "DESAPROBADO CON"
Txt_Prom.Text = Math.Round(Prom, 2)
End If
End Sub
Sub promediar()
Dim n1 As Integer
Dim n2 As Integer
Dim n3 As Integer
Dim prom As Double
n1 = Range("C12").Value
n2 = Range("D12").Value
n3 = Range("E12").Value
prom = (n1 + n2 + n3) / 3
If prom > 10.5 Then
Range("G12").Value = "APROBADO CON : " & Round(prom, 2)
Else
Range("G12").Value = "DESAPROBADO CON : " & Round(prom, 2)
End If
End Sub
Sub Promedio()
Dim n1 As Integer
Dim n2 As Integer
Dim n3 As Integer
Dim prom As Double
n1 = InputBox("INGRESE NOTA 01")
n2 = InputBox("INGRESE NOTA 02")
n3 = InputBox("INGRESE NOTA 03")
prom = (n1 + n2 + n3) / 3
If prom > 10.5 Then
MsgBox "APROBADO CON : " & Round(prom, 2)
Else
MsgBox "DESAPROBADO CON : " & Round(prom, 2)
End If
End Sub
Private Sub btn_calcular_Click()
Dim n1 As Integer
Dim n2 As Integer
Dim n3 As Integer
Dim prom As Double
n1 = txt_1.Text
n2 = txt_2.Text
n3 = txt_3.Text
prom = (n1 + n2 + n3) / 3
If prom > 10.5 Then
txt_prom.Text = "APROBADO CON " & Round(prom, 2)
Else
txt_prom.Text = "DESAPROBADO CON " & Round(prom, 2)
End If
End Sub