lunes, 25 de mayo de 2015

EJERCICIOS 02 UTILIZANDO IF ELSE



1.      Escriba un programa para determinar sí un número entero A es  divisible por otro B.



#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int A,B;
A=edNa->Text.ToInt();
B=edNb->Text.ToInt();
if (A%B==0)
edR->Text="es Divisible";
else
edR->Text="no es Divisible";

}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
edNa->Clear();
edNb->Clear();
edR->Clear();
edNa->SetFocus();

}


2.      Hacer un programa de tal manera que se ingrese las 2 evaluaciones de un alumno y reporte APROBADO si el promedio es mayor o igual a 10.5 y DESAPROBADO en caso contrario

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}


void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
edN1->Clear();
edN2->Clear();
edE->Clear();
edN1->SetFocus();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
float N1,N2,P;
N1=edN1->Text.ToDouble();
N2=edN2->Text.ToDouble();
P=(N1+N2)/2;
if (P>=10.5)
edE->Text="APROBADO";
else
edE->Text="DESAPROBADO";
}

3. -  Calcule el interés mensual generado por un capital. La tasa de interés mensual depende del capital que fue depositado. Si el capital es mayor que cero pero menor de 500, la tasa de interés será del 2% mensual. Si el capital es al menos 500 pero menor o igual a 1500 entonces la tasa de  interés es de 4.5%. Si el capital es mayor que 1500 la tasa de interés es del  9%. Se debe ingresar el capital y reportar el interés  

 


#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::salirClick(TObject *Sender)
{
Close();       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::calcularClick(TObject *Sender)
{
const float I1=0.02;
const float I2=0.045;
const float I3=0.09;
float c,i;
c=edC->Text.ToDouble();
if(c<=500)
i=c*I1;
else
if(c>=500 && c<=1500)
i=c*I2;
else
if(c>1500)
i=c*I3;
edI->Text=i;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::limpiarClick(TObject *Sender)
{
edC->Clear();
edI->Clear();
edC->SetFocus();
}
//---------------------------------------------------------------------------