PROGRAM 1= SIMPLE CALCULATOR.... XAML CODE= - TopicsExpress



          

PROGRAM 1= SIMPLE CALCULATOR.... XAML CODE= C# CODE,, using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; namespace Calculator { public partial class MainPage : PhoneApplicationPage { double num1, num2, res; String op; // Constructor public MainPage() { InitializeComponent(); } private void SHOW(object sender, RoutedEventArgs e) { LCD.Text +=(sender as Button).Content.ToString() ; } private void Button13_Click(object sender, RoutedEventArgs e) { if (LCD.Text == "") { } else { LCD.Text += "0"; } } private void Button14_Click(object sender, RoutedEventArgs e) { if (LCD.Text.IndexOf(".") < 0) { if (LCD.Text == "") { LCD.Text += "0."; } else { LCD.Text += "."; } } } private void button21_Click(object sender, RoutedEventArgs e) { LCD.Text = ""; } private void Button15_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Sin(hh); LCD.Text = "" + Math.Round(res, 2); } private void Button16_Click(object sender, RoutedEventArgs e) { num1 = Double.Parse(LCD.Text); op = "/"; LCD.Text = ""; } private void Button17_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Tan(hh); LCD.Text = "" + Math.Round(res, 2); } private void Button18_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Log(hh); LCD.Text = "" + Math.Round(res, 2); } private void Button19_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Ceiling(hh); LCD.Text = "" + Math.Round(res, 2); } private void Button20_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Floor(hh); LCD.Text = "" + Math.Round(res, 2); } private void button22_Click(object sender, RoutedEventArgs e) { LCD.Text = LCD.Text.Remove(LCD.Text.Length - 1); } private void Button4_Click(object sender, RoutedEventArgs e) { num1 = Double.Parse(LCD.Text); op = "+"; LCD.Text = ""; } private void Button8_Click(object sender, RoutedEventArgs e) { num1 = Double.Parse(LCD.Text); op = "-"; LCD.Text = ""; } private void Button12_Click(object sender, RoutedEventArgs e) { num1 = Double.Parse(LCD.Text); op = "*"; LCD.Text = ""; } private void button24_Click(object sender, RoutedEventArgs e) { double hh; hh = Double.Parse(LCD.Text); double res = Math.Cos(hh); LCD.Text = "" + Math.Round(res, 2); } private void button23_Click(object sender, RoutedEventArgs e) { num2 = Double.Parse(LCD.Text); if (op == "+") { res = num1 + num2; LCD.Text = res + ""; } else if (op == "-") { res = num1 - num2; LCD.Text = res + ""; } else if (op == "*") { res = num1 * num2; LCD.Text = res + ""; } else if (op == "/") { res = num1 / num2; LCD.Text = "" + Math.Round(res, 2); } } } }
Posted on: Sat, 24 Aug 2013 05:17:59 +0000

© 2015