Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Diagnostics;
  7. public class Form1
  8. {
  9.  
  10.     public class GlobalVariables
  11.     {
  12.  
  13.     }
  14.  
  15.  
  16.     private void Button1_Click(object sender, EventArgs e)
  17.     {
  18.         int A = 0;
  19.         int B = 0;
  20.         int C = 0;
  21.         double delta = 0;
  22.         A = TextBox1.Text;
  23.         B = TextBox2.Text;
  24.         C = TextBox3.Text;
  25.  
  26.  
  27.         Label4.Text = "";
  28.         Label5.Text = "";
  29.         Label6.Text = "";
  30.         Label7.Text = "";
  31.  
  32.         if (A == 0) {
  33.             Label4.Text = "To nie jest równanie kwadratowe: A = 0!";
  34.  
  35.         } else {
  36.             Label4.Text = "Równanie jest postaci :" + "y = {0}" + A + "x^2+" + B + "x+" + C;
  37.             delta = B * B - 4 * A * C;
  38.             Label5.Text = "Delta wynosi: {0}" + delta;
  39.  
  40.         }
  41.  
  42.         if (delta < 0) {
  43.             Label6.Text = "To równanie nie ma rozwiązania w zbiorze liczb rzeczywistych";
  44.  
  45.  
  46.         } else {
  47.  
  48.             if (delta == 0) {
  49.                 double wynik = 0;
  50.                 wynik = -B / (2 * A);
  51.                 Label7.Text = "To równanie posiada jeden pierwiastek, który wynosi x = " + wynik;
  52.  
  53.  
  54.             } else {
  55.                 double wynik1 = 0;
  56.                 double wynik2 = 0;
  57.  
  58.                 wynik1 = (-B + Math.Sqrt(delta)) / (2 * A);
  59.                 wynik2 = (-B - Math.Sqrt(delta)) / (2 * A);
  60.                 Label7.Text = "To równanie posiada dwa pierwiastki, które wynoszą odpowiednio: " + Constants.vbLf + " x1 = " + wynik1 + " oraz x2 = " + wynik2;
  61.  
  62.             }
  63.  
  64.         }
  65.  
  66.     }
  67.  
  68.  
  69.     private void Form1_Load(object sender, EventArgs e)
  70.     {
  71.         Label4.Text = "";
  72.         Label5.Text = "";
  73.         Label6.Text = "";
  74.         Label7.Text = "";
  75.  
  76.     }
  77.     public Form1()
  78.     {
  79.         Load += Form1_Load;
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement