Ex2+T2+Question+4

==The next task is to do a convertor. This is a program that will enable students to convert from any Standard Value to a Metric Value and vice versa. You are only required to program inside each button. Here are some important points:== · The convertor should allow students to convert both ways from: o Fahrenheit to Celsius (button1). o Centimeter to Feet (button2). o Centimeter to inches (button3). o From Pounds to Kilograms (button4). · The user is will write the number to be converted into TextBox1. · You should tackle down any problem that the program may face because of misuse. · The only thing that shouldn’t be tackled down is if the user enters text data instead of a number.

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 WindowsFormsApplication4 { public partial class   Form1  :  Form  { float a;  float  b;  float  c;  float  d;

public Form1 { InitializeComponent; } private void  textBox1_TextChanged(  object  sender,  EventArgs  e) { } private void  button1_Click(  object  sender,  EventArgs  e) { if (textBox1.TextLength == 0) { MessageBox  .Show(  "Escribe algo!!!"  ); } else

{ a = float  .Parse(textBox1.Text); textBox1.Text = ""  + ((  float  .Parse(textBox1.Text) - 32) * (5.0 / 9.0)); } } private void  button2_Click(  object  sender,  EventArgs  e) { if (textBox1.TextLength == 0) { MessageBox  .Show(  "Escribe algo!!!"  ); } else

{ b = float  .Parse(textBox1.Text); textBox1.Text = ""  + ((  float  .Parse(textBox1.Text) / 30.48)); } } private void  button3_Click(  object  sender,  EventArgs  e) { if (textBox1.TextLength == 0) { MessageBox  .Show(  "Escribe algo!!!"  ); } else

{ c = float  .Parse(textBox1.Text); textBox1.Text = ""  + ((  float  .Parse(textBox1.Text) / 2.54)); } } private void  button4_Click(  object  sender,  EventArgs  e) { if (textBox1.TextLength == 0) { MessageBox  .Show(  "Escribe algo!!!"  ); } else

{ d = float  .Parse(textBox1.Text); textBox1.Text = ""  + ((  float  .Parse(textBox1.Text) / .45359)); } } } }

OR

mespace wikiexam_juan_jan_rodrigo { public   partial   class   Form1  :  Form

{ int  a;  int  b;  public  Form1 {

InitializeComponent; } private   void  button1_Click(  object  sender,  EventArgs  e) { int a;  int  a =  Int32  .Parse(textBox1.Text); textBox2.Text = Int32  .Parse (a + (-32 * 5 / 9); }  private   void  button2_Click(  object  sender,  EventArgs  e) {  int  first =  Int32  .Parse (textBox1.Text) ;  int  Second =  Int32  .Parse(textBox2.Text); textBox3.Text =  Int32  .Parse ((textBox2.Text + textBox1.Text)/30.48); }  private   void  button3_Click(  object  sender,  EventArgs  e) {  int  first =  Int32  .Parse(textBox1.Text);  int  Second =  Int32  .Parse(textBox2.Text); textBox3.Text = ((textBox2.Text + textBox1.Text) / 2.54); }  private   void  button4_Click(  object  sender,  EventArgs  e) {  int  first =  Int32  .Parse (textBox1.Text) ;  int  Second =  Int32  .Parse(textBox2.Text); textBox3.Text = ((textBox2.Text + textBox1)/.45359);