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 Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace Regla_Cramer
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class Resulltado : ContentPage
- {
- public Resulltado(double x1, double x2, double y1, double y2, double r1, double r2 )
- {
- InitializeComponent();
- try {
- //calculando viabilidad de la ecuación
- double e = Calcular(x1, x2, y1, y2);
- if (Math.Abs(e) < 1E-10)
- {
- DisplayAlert("Error", "El sistema no tiene solución", "OK");
- }
- //calculando solución
- else
- {
- double Dx = Calcular(r1, y1, r2, y2);
- double Dy = Calcular(x1, r1, x2, r2);
- e1.Text = $" X1={x1} Y1={y1} = {r1}";
- e2.Text = $" X2={x2} Y2={y2} = {r2}";
- ds.Text = $" D=({x1}*{y2})-({y2}*{x2})={e}";
- double x = Dx / e;
- double y = Dy / e;
- dx.Text = $"Dx= ({r1}*{y2})-({y1}*{r2})={Dx}";
- dy.Text = $"Dy= ({x1}*{r2})-({r1}*{x2})={Dy}";
- //calculando resultados
- xF.Text = $" X= {Dx}/{e}={x}";
- yF.Text = $"Y= {Dy}/{e}={y}";
- }
- } catch (DivideByZeroException) {
- DisplayAlert("Error", "Division por 0", "OK");
- }catch (Exception ex)
- {
- DisplayAlert("Error", ex.Message, "OK");
- }
- }
- private double Calcular(double x1, double x2, double y1, double y2) {
- return (x1 * y2) - (y1 * x2);
- }
- private async void Button_Clicked(object sender, EventArgs e)
- {
- await Navigation.PopModalAsync();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment