sexta-feira, 14 de maio de 2010

Controle de M3

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 Exercicio
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
double faixa1, faixa2, faixa3, faixa4, faixa5, consumo, controle;
consumo = Convert.ToDouble(txbConsumo.Text);
if (consumo > 0 && consumo<=15)
{
faixa1 = consumo * 1.553;
controle = (faixa1);
lsbresposta.Items.Add("consumo M3 = "+controle );
}
else
if (consumo >= 15 && consumo <= 30)
{
faixa2 = (consumo - 15) * 3.417;
faixa1 = 15 * 1.553;
controle = (faixa1 + faixa2);
lsbresposta.Items.Add("consumo M3 = "+controle );
}
else
if (consumo >= 30 && consumo <= 45)
{
faixa3 = (consumo - 30) * 4.659;
faixa2 = 15 * 3.417;
faixa1 = 15 * 1.553;
controle = (faixa1 + faixa2 + faixa3);
lsbresposta.Items.Add("consumo M3 = "+controle );
}
else
if (consumo >= 45 && consumo <= 60)
{
faixa4 = (consumo - 45) * 9.319;
faixa3 = 15 * 4.659;
faixa2 = 15 * 3.417;
faixa1 = 15 * 1.553;
controle = (faixa1 + faixa2 + faixa3 + faixa4);
lsbresposta.Items.Add("consumo M3 = "+controle );
}
else
{
faixa5 = (consumo - 60) * 12.426;
faixa4 = 15 * 9.319;
faixa3 = 15 * 4.659;
faixa2 = 15 * 3.417;
faixa1 = 15 * 1.553;
controle = (faixa1 + faixa2 + faixa3 + faixa4 + faixa5);
lsbresposta.Items.Add("consumo M3 = "+controle );
}
}
private void button2_Click(object sender, EventArgs e)
{
txbConsumo.Clear();
lsbresposta.Items.Clear();
}
}
}

Nenhum comentário:

Postar um comentário