poszukuję pomocy w napisaniu programu w Visual Studio.
Program ma mieć prosty interfejs graficzny.
Treść zadania:
Napisz program, którego zadaniem będzie rozwiązanie równania (kwadratowego), zdefiniowanego przez użytkownika. Użytkownik podaje parametry (a,b,c) równania y = ax2 + bx + c (kwadratowego) i wyświetla rozwiązanie równania. Program ma być odporny na wprowadzenie przypadkowego znaku (w miejscu gdzie jest oczekiwana liczba).
Co według Ciebie jest pomocą
? Bo na tym forum pomoc
występuje wtedy, gdy użytkownik zacznie sam rozwiązywać problem i zatrzyma się na którymś momencie. Ty nie podszedłeś jeszcze do rozwiązywania tego zadania.
-
Funkcje
http://cpp0x.pl/kursy/Kurs-C++/Poziom-2/Funkcje-pierwsze-starcie/291
a) funkcja obliczajaca równanie kwadratowe
b) funkcja sprawdzająca czy to co wpisałeś jest prawidłowe
c) funkcja main() -
Warunki
a) if()else()
http://cpp0x.pl/kursy/Kurs-C++/Poziom-1/Instrukcja-warunkowa-if-else/16 -
wejście wyjście (wpisywanie liczb i wyświetlanie wyniku)
http://www.algorytm.edu.pl/wstp-do-c/standardowe-wejciewyjcie.html
Podpowiedzi:
- Aby sprawdzić, czy to co wpisał uzytkownik jest liczbą zapisz wpierw to jako tekst i sprawdź znak po znaku czy jest cyfrą. Jeśli tak, to znaczy, że jest OK!
- Ogarnij sobie te funkcje:
double wynik(double a, double b, double c);
bool CzyJestLiczba(char *tekst); (można uzyć gotowych funkcji ale przecież na tym polega cała zabawa !)
int main();
- funkcja potegujaca znajduje się w bibliotece <cmath>
http://cpp0x.pl/dokumentacja/standard-C/pow/34
Powodzenia. Jeśli na czymś staniesz to pisz.
#pragma once
namespace Project4 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
double a = 0;
double b = 0;
double c = 0;
double d = 0;
double sqrt(double d);
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label10;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label9 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label10 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(36, 39);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(19, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"a=";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(36, 81);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(19, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"b=";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(36, 119);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(19, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"c=";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(44, 194);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(24, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"x1=";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(44, 219);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(24, 13);
this->label5->TabIndex = 4;
this->label5->Text = L"x2=";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(91, 194);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(35, 13);
this->label6->TabIndex = 5;
this->label6->Text = L"label6";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(91, 219);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(35, 13);
this->label7->TabIndex = 6;
this->label7->Text = L"label7";
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(3, 232);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(35, 13);
this->label8->TabIndex = 7;
this->label8->Text = L"label8";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(77, 36);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(32, 20);
this->textBox1->TabIndex = 8;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(78, 78);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(31, 20);
this->textBox2->TabIndex = 9;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(78, 116);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(31, 20);
this->textBox3->TabIndex = 10;
//
// label9
//
this->label9->AutoSize = true;
this->label9->Location = System::Drawing::Point(91, 171);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(35, 13);
this->label9->TabIndex = 11;
this->label9->Text = L"label9";
//
// button1
//
this->button1->Location = System::Drawing::Point(157, 60);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 12;
this->button1->Text = L"oblicz";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// label10
//
this->label10->AutoSize = true;
this->label10->Location = System::Drawing::Point(44, 171);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(36, 13);
this->label10->TabIndex = 13;
this->label10->Text = L"delta=";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 273);
this->Controls->Add(this->label10);
this->Controls->Add(this->button1);
this->Controls->Add(this->label9);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
a = Double::Parse(textBox1->Text);
b = Double::Parse(textBox2->Text);
c = Double::Parse(textBox3->Text);
d = ((b*b)-(4*a*c));
label9->Text = ""+d;
if(d==0)
{
label8->Text="funkcja kwadratowa ma jedno miejsce zerowe i jest nim="+((-b)/(2*a));
}
else if(d<0)
{ label8->Text="funkcja kwadratowa nie ma miejsc zerowych";
}
else if(d>0)
{
label8->Text="funkcja kwadratowa ma dwa miejsca zerowe";
label6->Text="x1"+(-b-sqrt(d));
}
}
};
}
nie działa mi sqrt dlaczego?
Ojezunazaretańskiimatkobosko.
Co byś powiedział na to, że sam zerkniesz do dokumentacji i dojdziesz do tego co jest źle.
Programowanie nie polega na zgadywaniu.
PS funkcja kwadratowa ma zawsze dwa miejsca zerowe, a to, że czasem są one równe bądź urojone to inna sprawa. Czyli nie funkcja kwadratowa nie ma miejsc zerowych
, tylko ta funkcja kwadratowa nie ma rzeczywistych miejsc zerowych
. Bycie ścisłym to istotna kwestia.
Patryk27 napisał(a):
Ojezunazaretańskiimatkobosko.
Co byś powiedział na to, że sam zerkniesz do dokumentacji i dojdziesz do tego co jest źle.
Programowanie nie polega na zgadywaniu.PS funkcja kwadratowa ma zawsze dwa miejsca zerowe, a to, że czasem są one równe bądź urojone to inna sprawa. Czyli nie
funkcja kwadratowa nie ma miejsc zerowych
, tylkota funkcja kwadratowa nie ma rzeczywistych miejsc zerowych
. Bycie ścisłym to istotna kwestia.
dobra zmienione na ta funkcja, z tymi dokumentacjami to juz mam dość..bo przejrzałem już milion i nie mogę dojść gdzie robię błąd, a to i tak jeszcze nie koniec bo muszę jeszcze zabezpieczyć w przypadku wpisania nie odpowiedniego znaku
czy ktoś może pomóc ?
Skoro piszesz w .NET, to może łatwiej użyć Math::Sqrt
?
W ogóle czemu nie piszesz w C#?
w roku 1998 przy pomocy delphi 3 i standardowych funkcji
zrobilem taki interface do rysowania funkcji sinus do kwadratowej tez sie nadawal tylko trzeba bylo pare rzeczy zmienic i kompilowac od nowa
niestety kod zaginal
troche jest w pamieci :) ale nie chce mi sie do tego wracac
tworze interfejs GUI i go oprogramowuje, może być i w c++ bo c# nie znam w ogóle , to co zmienić żeby zadziałało ?
#pragma once
namespace Project4 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
double a = 0;
double b = 0;
double c = 0;
double d = 0;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label10;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label9 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label10 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(36, 39);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(19, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"a=";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(36, 81);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(19, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"b=";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(36, 119);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(19, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"c=";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(44, 194);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(24, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"x1=";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(44, 219);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(24, 13);
this->label5->TabIndex = 4;
this->label5->Text = L"x2=";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(91, 194);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(35, 13);
this->label6->TabIndex = 5;
this->label6->Text = L"label6";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(91, 219);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(35, 13);
this->label7->TabIndex = 6;
this->label7->Text = L"label7";
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(3, 232);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(35, 13);
this->label8->TabIndex = 7;
this->label8->Text = L"label8";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(77, 36);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(32, 20);
this->textBox1->TabIndex = 8;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(78, 78);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(31, 20);
this->textBox2->TabIndex = 9;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(78, 116);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(31, 20);
this->textBox3->TabIndex = 10;
//
// label9
//
this->label9->AutoSize = true;
this->label9->Location = System::Drawing::Point(91, 171);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(35, 13);
this->label9->TabIndex = 11;
this->label9->Text = L"label9";
//
// button1
//
this->button1->Location = System::Drawing::Point(157, 60);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 12;
this->button1->Text = L"oblicz";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// label10
//
this->label10->AutoSize = true;
this->label10->Location = System::Drawing::Point(44, 171);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(36, 13);
this->label10->TabIndex = 13;
this->label10->Text = L"delta=";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 273);
this->Controls->Add(this->label10);
this->Controls->Add(this->button1);
this->Controls->Add(this->label9);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
a = Double::Parse(textBox1->Text);
b = Double::Parse(textBox2->Text);
c = Double::Parse(textBox3->Text);
d = ((b*b)-(4*a*c));
label9->Text = ""+d;
if(d==0)
{
label8->Text="ta funkcja kwadratowa ma jedno miejsce zerowe i jest nim="+((-b)/(2*a));
}
else if(d<0)
{ label8->Text="ta funkcja kwadratowa nie ma miejsc zerowych";
}
else if(d>0)
{
label8->Text="ta funkcja kwadratowa ma dwa miejsca zerowe";
label6->Text="x1"+(-b-sqrt(d));
}
}
};
}
w CLR dokladnie
wywala: error C3861: 'sqrt': identifier not found
No pisałem już, żebyś spróbował zamiast sqrt
użyć Math::Sqrt
. Co jeszcze mogę zrobić? Wbić na chatę i wpisać to za Ciebie? :|
somekind napisał(a):
No pisałem już, żebyś spróbował zamiast
sqrt
użyćMath::Sqrt
. Co jeszcze mogę zrobić? Wbić na chatę i wpisać to za Ciebie? :|
dziala ! dziekowac i przepraszac za swoj nieprofesjonalizm
Sqrt
to nie to samo co sqrt
może być i w c++ bo c# nie znam w ogóle
C++ tez nie znasz. Zacznij to robic w C# wszystko od poczatku (wywal wszystko to co masz) i szukaj tutoriali po C# jak napisac rownanie kwadratowe w C#...
edit nie zauwazylem ze jest druga strona...
#pragma once
namespace Project4 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(127, 45);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"Oblicz ";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(40, 118);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(35, 13);
this->label1->TabIndex = 1;
this->label1->Text = L"label1";
this->label1->Visible = false;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(16, 156);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(18, 13);
this->label2->TabIndex = 2;
this->label2->Text = L"x1";
this->label2->Visible = false;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(16, 185);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(18, 13);
this->label3->TabIndex = 3;
this->label3->Text = L"x2";
this->label3->Visible = false;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(12, 25);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(22, 13);
this->label4->TabIndex = 7;
this->label4->Text = L"a =";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(11, 51);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(19, 13);
this->label5->TabIndex = 8;
this->label5->Text = L"b=";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(11, 77);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(19, 13);
this->label6->TabIndex = 9;
this->label6->Text = L"c=";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(36, 22);
this->textBox1->Name = L"textBox1";
this->textBox1->RightToLeft = System::Windows::Forms::RightToLeft::No;
this->textBox1->Size = System::Drawing::Size(55, 20);
this->textBox1->TabIndex = 4;
this->textBox1->Click += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(36, 48);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(55, 20);
this->textBox2->TabIndex = 5;
this->textBox2->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox2_TextChanged);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(36, 70);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(55, 20);
this->textBox3->TabIndex = 6;
this->textBox3->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox3_TextChanged);
//
// button2
//
this->button2->Location = System::Drawing::Point(127, 70);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 10;
this->button2->Text = L"Zamknij";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(40, 142);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(35, 13);
this->label7->TabIndex = 11;
this->label7->Text = L"label7";
this->label7->Visible = false;
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(127, 13);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(59, 13);
this->label8->TabIndex = 12;
this->label8->Text = L"ax^2+bx+c";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(295, 261);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"funkcja kwadratowa";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
System::Double liczba;
if (!System::Double::TryParse(textBox1->Text->ToString(), liczba))
{
MessageBox::Show("podaj liczbe");
}
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
System::Double liczba;
if (!System::Double::TryParse(textBox2->Text->ToString(), liczba))
{
MessageBox::Show("podaj liczbe");
}
}
private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
System::Double liczba;
if (!System::Double::TryParse(textBox3->Text->ToString(), liczba))
{
MessageBox::Show("podaj liczbe");
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double a, b, c, d, z;
a = System::Convert::ToDouble(textBox1->Text);
b = System::Convert::ToDouble(textBox2->Text);
c = System::Convert::ToDouble(textBox3->Text);
d = (b*b) - (4 * a*c);
z = Math::Sqrt(d);
label1->Text =" delta=" + System::Convert::ToString(d);
if (d>0){
label1->Visible=true;
label2->Visible=true;
label3->Visible=true;
label7->Visible=true;
label2->Text = "x1 = " + (-b + z) / (2 * a);
label3->Text = "x2 = " + (b + z) / (2 * a);
label7->Text =" Ta funkcja kwadratowa ma dwa miejsca zerowe";
}
if (d == 0) {
label1->Visible=true;
label2->Visible=true;
label3->Visible=false;
label7->Visible=true;
label2->Text = "x1 = " + (-b/(2*a));
label7->Text =" Ta funkcja kwadratowa ma jedno miejsce zerowe";
}
if (d < 0){
label1->Visible=true;
label2->Visible =false;
label3->Visible= false;
label7->Visible= true;
label7->Text=" Ta funkcja kwadratowa nie ma miejsc zerowych";
}
}
};
}
wszystko działa, tylko jak zrobić gdy w okienku na parametr a b lub c nie wpiszemy nic nie wywalało programu