Você está na página 1de 3

Informtica para Engenharia Puc-Campinas

Descrio do Projeto: ndice de massa corporal

Desenvolvido por: Alunos de Engenharia

Data:

Verso: 1.0

LayOut do Formulrio

Objeto Propriedades Valor


form1 Text ndice Massa Corporal
StartPosition CenterScreen
label1 Text Peso
label2 Text Kg
label3 Text Altura
label4 Text metros
label5 Text IMC = peso / (altura * altura) =
label6 Text
label7 Text
textBox1 Text
textBox2 Text
pictureBox1 Image

Visible False
pictureBox 2 Image

Visible False
pictureBox 3 Image

Visible False
button1 Text &Calcular
button2 Text &Limpar
button3 Text Sai&r

Projeto
Informtica para Engenharia Puc-Campinas
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IMC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
double peso, altura, imc;
#region "Entrada de dados"
try
{

peso = double.Parse(textBox1.Text);
altura = double.Parse(textBox2.Text);
if (peso < 0 || peso > 250 || altura < 0.5 || altura > 2.3)
{
MessageBox.Show("Entradas de Dados Invlidas\nDigite as entradas
novamente!!!",
"****** VALORES INVLIDAS ******",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
textBox1.Text = "";
textBox2.Text = "";
label6.Text = "";
label7.Text = "";
textBox1.Focus();
}
else
{
imc = peso / (altura * altura);
imc = Math.Round(imc, 2);
label6.Text = imc.ToString();
if (imc < 18.5)
{
pictureBox1.Visible = true;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
label7.Text = "Abaixo do Peso";
}
if (imc >= 18.5 && imc < 24.9)
{
pictureBox1.Visible = false;
pictureBox2.Visible = true;
pictureBox3.Visible = false;
label7.Text = "Peso Normal";
}
if (imc >= 24.9)
{
pictureBox1.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = true;
label7.Text = "Obsidade";
}
}
}
catch (Exception erro)
{
MessageBox.Show(erro.Message, "***** ERRO ***** ",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
textBox1.Text = "";
textBox2.Text = "";
label6.Text = "";
label7.Text = "";

Projeto
Informtica para Engenharia Puc-Campinas
textBox1.Focus();
}
#endregion
}

private void button2_Click(object sender, EventArgs e)


{
textBox1.Text = "";
textBox2.Text = "";
label6.Text = "";
label7.Text = "";
pictureBox1.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
textBox1.Focus();
}

private void button3_Click(object sender, EventArgs e)


{
string texto = "Deseja sair do Programa ndice de Massa Muscular";
string titulo = "++++++++ FINALIZANDO ++++++++";
if (MessageBox.Show(texto, titulo, MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
Application.Exit();
}
}
}
}

Projeto

Você também pode gostar