Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Misvaha_Ribuit_Slover
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- decimal a, b, c, Delta, X1, X2, Delta_Sqrt1, X_kodkod, Y_kodkod;
- double Delta_Sqrt;
- private void Num_A_ValueChanged(object sender, EventArgs e)
- {
- if (Num_A.Value == 0)
- Num_A.ForeColor = System.Drawing.Color.Red;
- else
- Num_A.ForeColor = System.Drawing.SystemColors.WindowText;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- a = Num_A.Value;
- b = Num_B.Value;
- c = Num_C.Value;
- if (a == 0)
- MessageBox.Show("a cannot be 0");
- else
- {
- Delta = b * b - 1 * (4) * (a) * (c);
- textBox_Solution.Text = "▲ = " + b.ToString() + "² " + "-4 * " + a.ToString() + " * " + c.ToString();
- textBox_Solution.Text += "\r\n▲ = " + Delta.ToString();
- Delta_Sqrt = Math.Sqrt((double)Delta);
- textBox_Solution.Text += "\r\n√" + Delta.ToString() + " = " + Delta_Sqrt.ToString();
- X_kodkod = (b * (-1)) / (2 * a); /*חישוב נקודת קודקוד*/
- Y_kodkod = (Delta * (-1)) / (4 * a);
- textBox_Kodkod.Text = "( " + X_kodkod.ToString() + ", " + Y_kodkod.ToString() + " )";
- if (b >= 0) /* חישוב ניגזרת */
- textBox_Nigzeret.Text = "Y' = " +(2 * a).ToString() + "X + " + b.ToString();
- else
- textBox_Nigzeret.Text = "Y' = " + (2 * a).ToString() + "X " + b.ToString();
- if(a > 0) /* עלייה או ירידה */
- textBox_upORdown.Text = "עולה";
- if (a < 0)
- textBox_upORdown.Text = "יורדת";
- if (Delta < 0) /* פתירת המשוואה הריבועית */
- textBox_Solution.Text += "\r\nאין פיתרון!";
- if (Delta == 0)
- {
- textBox_Solution.Text += "\r\nX1,2 = (" + (b * -1).ToString() + " ± 0) /" + (2 * a).ToString();
- X1 = (b * -1) / (2 * a);
- textBox_Solution.Text += "\r\nX = " + X1.ToString();
- textBox_X1.Text = "X1 = " + X1.ToString();
- }
- if (Delta > 0)
- {
- textBox_Solution.Text += "\r\nX = (" + (b * -1).ToString() + " ± " + Delta_Sqrt.ToString() + ") /" + (2 * a).ToString();
- Delta_Sqrt1 = (decimal)Delta_Sqrt;
- X1 = ((b * -1) + Delta_Sqrt1) / (2 * a);
- X2 = ((b * -1) - Delta_Sqrt1) / (2 * a);
- textBox_Solution.Text += "\r\nX1 = " + X1.ToString();
- textBox_X1.Text = "X1 = " + X1.ToString();
- textBox_Solution.Text += "\r\nX2 = " + X2.ToString();
- textBox_X2.Text = "X2 = " + X2.ToString();
- }
- if (a < 0 && Y_kodkod < 0) /* מציאת תחום שליליות וחיוביות */
- {
- textBox_Up_Point.Text = "אין";
- textBox_Down_Point.Text = "כל X";
- textBox_Down.Text = "X<" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X>" + Y_kodkod.ToString("0.###");
- }
- if (a < 0 && Y_kodkod > 0)
- {
- textBox_Up_Point.Text = X1.ToString("0.###") + "<X<" + X2.ToString("0.###");
- textBox_Down_Point.Text = X1.ToString("0.###") + ">X>" + X2.ToString("0.###");
- textBox_Down.Text = "X<" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X>" + Y_kodkod.ToString("0.###");
- }
- if (a < 0 && Y_kodkod == 0)
- {
- textBox_Up_Point.Text = "אין";
- textBox_Down_Point.Text = "x<" + X1.ToString("0.###") + "<x";
- textBox_Down.Text = "X<" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X>" + Y_kodkod.ToString("0.###");
- }
- if (a > 0 && Y_kodkod > 0)
- {
- textBox_Up_Point.Text = "כל X";
- textBox_Down_Point.Text = "אין";
- textBox_Down.Text = "X>" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X<" + Y_kodkod.ToString("0.###");
- }
- if (a > 0 && Y_kodkod < 0)
- {
- textBox_Up_Point.Text = X1.ToString("0.###") + ">X>" + X2.ToString("0.###");
- textBox_Down_Point.Text = X1.ToString("0.###") + "<X<" + X2.ToString("0.###");
- textBox_Down.Text = "X>" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X<" + Y_kodkod.ToString("0.###");
- }
- if (a > 0 && Y_kodkod == 0)
- {
- textBox_Up_Point.Text = "x<" + X1.ToString("0.###") + "<x";
- textBox_Down_Point.Text = "אין";
- textBox_Down.Text = "X>" + X_kodkod.ToString("0.###");
- textBox_Up.Text = "X<" + Y_kodkod.ToString("0.###");
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error [ " + ex.Message + " ]");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment