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.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace WpfApp3
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void oblicz_Click(object sender, RoutedEventArgs e)
- {
- double a = Convert.ToDouble(paramter_a.Text);
- double b = Convert.ToDouble(paramter_b.Text);
- double c = Convert.ToDouble(paramter_c.Text);
- if (a != 0) funkcjaKwadratowa(a, b, c);
- else if (b != 0) fukncjaLiniowa(b, c);
- else rownanie(c);
- }
- private void rownanie(double a)
- {
- komentarz.Content = String.Format("Rozwiazywanie rownania f(x) = {0}", a);
- if (a == 0)
- {
- out_x1.Content = "inf.";
- out_x2.Content = "inf.";
- }
- else
- {
- out_x1.Content = "brak";
- out_x2.Content = "brak";
- }
- }
- private void fukncjaLiniowa(double a, double b)
- {
- komentarz.Content = String.Format("Rozwiazywanie rownania f(x) = {0}x + {1}", a, b);
- out_x1.Content = (-b) / a;
- out_x2.Content = "brak";
- }
- private void funkcjaKwadratowa(double a, double b, double c)
- {
- komentarz.Content = String.Format("Rozwiazywanie rownania f(x) = {0}x^2 + {1}x + {2}", a, b, c);
- double delta = (b * b) - (4 * a * c);
- if (delta > 0)
- {
- double x1 = (-b - Math.Sqrt(delta) / (2 * a));
- double x2 = (-b + Math.Sqrt(delta) / (2 * a));
- out_x1.Content = x1;
- out_x2.Content = x2;
- }
- else if (delta == 0)
- {
- out_x1.Content = (-b) / (2 * a);
- out_x2.Content = "brak";
- }
- else
- {
- out_x1.Content = "brak";
- out_x2.Content = "brak";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement