Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Drawing;
- using System.Windows.Forms;
- namespace GUI
- {
- class Program
- {
- static TextBox txtFah;
- static TextBox txtCel;
- static Button toFah;
- static Button toCel;
- static void Main(string[] args)
- {
- txtFah = new TextBox();
- txtCel = new TextBox();
- toFah = new Button();
- toCel = new Button();
- Form appForm;
- appForm = new Form();
- appForm.Size = new Size(600, 250);
- appForm.Text = "Temperature Converter";
- Label Fah = new Label();
- Fah.Size = new Size(100, 50);
- Fah.Text = "Fahrenheit";
- Fah.Location = new Point(50, 50);
- appForm.Controls.Add(Fah);
- txtFah = new TextBox();
- txtFah.Size = new Size(150, 100);
- txtFah.Location = new Point(120, 50);
- appForm.Controls.Add(txtFah);
- toCel = new Button();
- toCel.Size = new Size(150, 25);
- toCel.Text = "To Celsius";
- toCel.Location = new Point(300, 50);
- appForm.Controls.Add(toCel);
- Label Cel = new Label();
- Cel.Size = new Size(100, 100);
- Cel.Text = "Celsius";
- Cel.Location = new Point(50, 120);
- appForm.Controls.Add(Cel);
- txtCel = new TextBox();
- txtCel.Size = new Size(150, 100);
- txtCel.Location = new Point(120, 110);
- appForm.Controls.Add(txtCel);
- toFah = new Button();
- toFah.Size = new Size(150, 25);
- toFah.Text = "To Farenheit";
- toFah.Location = new Point(300, 105);
- appForm.Controls.Add(toFah);
- Application.Run(appForm);
- }
- private static void toFah_Click(object sender, EventArgs e)
- {
- Double number = Convert.ToDouble(txtCel.Text);
- Double farenheit = (number - 32) / 9 * 5;
- // String formatedNumber = String.Format("{0:f1}", number);
- String formatedFareheit = String.Format("{0:f1}", txtFah.Text);
- // Console.WriteLine(formatedNumber + " " + (char)176 + "F is = " + formatedFareheit + " " + (char)176 + "C");
- }
- private static void toCel_Click(object sender, EventArgs e)
- {
- Double number = Convert.ToDouble(txtFah.Text);
- Double celsius = (number / 5) * 9 + 32;
- //String secondNumber = String.Format("{0:f1}", number);
- String formatedCelsius = String.Format("{0:f1}", txtCel.Text);
- //Console.WriteLine(secondNumber + " " + (char)176 + "C is = " + formatedCelsius + " " + (char)176 + "F");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement