Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лабораторная работа №1.docx
Скачиваний:
8
Добавлен:
04.03.2022
Размер:
356.72 Кб
Скачать

7 Код программы

Код программы, предназначенной для расчета формулы 1 и 2 представлен ниже:

Forms1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Второй_курс

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void label3_Click(object sender, EventArgs e)

{

}

private void label2_Click(object sender, EventArgs e)

{

}

private void label9_Click(object sender, EventArgs e)

{

}

private void label10_Click(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

Form2 f = new Form2();

this.Hide();

f.ShowDialog();

}

}

}

Forms2.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Второй_курс

{

public partial class Form2 : Form

{

public Form2()

{

InitializeComponent();

}

private void timer1_Tick(object sender, EventArgs e)

{

progressBar1.Maximum = 1000;

progressBar1.Value = 0;

for (int i = 0; i <= progressBar1.Maximum - 1; i++)

{

progressBar1.Increment(1);

label1.Text = progressBar1.Value.ToString();

label1.Refresh();

}

if (progressBar1.Value==progressBar1.Maximum)

{

timer1.Enabled = false;

Form3 f =new Form3();

this.Hide();

f.ShowDialog();

}

}

}

}

Forms3.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Второй_курс

{

public partial class Form3 : Form

{

public Form3()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Application.Exit();

}

private void button1_Click_1(object sender, EventArgs e)

{

Form1 f = new Form1();

this.Hide();

f.ShowDialog();

}

private void button2_Click(object sender, EventArgs e)

{

double m = Convert.ToDouble(textBox1.Text);

double c = Convert.ToDouble(textBox2.Text);

double x = Convert.ToDouble(textBox3.Text);

double a = Convert.ToDouble(textBox6.Text);

double b = Convert.ToDouble(textBox7.Text);

double z = (Math.Sin(x)/Math.Sqrt(1+m*m*Math.Sin(x)*Math.Sin(x)))-c*m*Math.Log10(m*x);

double s = Math.Exp(-a*x)*Math.Sqrt(x+1)+Math.Exp(-b*x)*Math.Sqrt(x+1.5);

textBox4.Text = z.ToString("n");

textBox5.Text = s.ToString("n");

}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox1.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

textBox2.Focus();

}

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox2.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

textBox3.Focus();

}

private void textBox3_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox3.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

button2.Focus();

}

private void textBox4_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox3.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

button2.Focus();

}

private void textBox5_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox3.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

button2.Focus();

}

private void textBox6_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox3.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

button2.Focus();

}

private void textBox7_KeyPress(object sender, KeyPressEventArgs e)

{

if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))

{

if (!(e.KeyChar.ToString() == "," && textBox3.Text.IndexOf(",") == -1) && !(e.KeyChar.ToString() == "-"))

e.Handled = true;

}

if (e.KeyChar.Equals((char)13))

button2.Focus();

}

private void label2_Click(object sender, EventArgs e)

{

}

private void label3_Click(object sender, EventArgs e)

{

}

}

}

Соседние файлы в предмете Технологии программирования