using var cl new FileStream figyru txt FileMode Truncate double x1 x2

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using (var cl = new FileStream(@"figyru.txt", FileMode.Truncate)) { }
double x1, x2, x3, x4, y1, y2, y3, y4, ab, bc, cd, da, ac, bd, h=0,p,s;
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" ||
textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "")
MessageBox.Show("Введіть дані");
else
{
x1 = Convert.ToDouble(textBox1.Text);
y1 = Convert.ToDouble(textBox2.Text);
x2 = Convert.ToDouble(textBox3.Text);
y2 = Convert.ToDouble(textBox4.Text);
x3 = Convert.ToDouble(textBox5.Text);
y3 = Convert.ToDouble(textBox6.Text);
x4 = Convert.ToDouble(textBox7.Text);
y4 = Convert.ToDouble(textBox8.Text);
if (comboBox1.SelectedIndex == 0)
{
if (textBox17.Text == "")
MessageBox.Show("Введіть дані");
else
h = Convert.ToDouble(textBox17.Text);
if ((x3 - x4) != (x2 - x1) || textBox8.Text!=textBox2.Text || textBox4.Text!=textBox6.Text)
MessageBox.Show("Введіть вірні дані");
else
{
ab = Math.Sqrt((Math.Pow(x2 - x1, 2)) + (Math.Pow(y2 - y1, 2)));
bc = Math.Sqrt((Math.Pow(x3 - x2, 2)) + (Math.Pow(y3 - y2, 2)));
cd = Math.Sqrt((Math.Pow(x4 - x3, 2)) + (Math.Pow(y4 - y3, 2)));
da = Math.Sqrt((Math.Pow(x1 - x4, 2)) + (Math.Pow(y1 - y4, 2)));
ac = Math.Sqrt((Math.Pow(x3 - x1, 2)) + (Math.Pow(y3 - y1, 2)));
bd = Math.Sqrt((Math.Pow(x4 - x2, 2)) + (Math.Pow(y4 - y2, 2)));
p = 2 * (ab + bc);
s = ac * h;
textBox9.Text = Convert.ToString(Math.Round(ab, 3));
textBox10.Text = Convert.ToString(Math.Round(bc, 3));
textBox11.Text = Convert.ToString(Math.Round(cd, 3));
textBox12.Text = Convert.ToString(Math.Round(da, 3));
textBox13.Text = Convert.ToString(Math.Round(ac, 3));
textBox14.Text = Convert.ToString(Math.Round(bd, 3));
textBox15.Text = Convert.ToString(Math.Round(p, 3));
textBox16.Text = Convert.ToString(Math.Round(s, 3));
using (var txt = File.AppendText(@"figyru.txt"))
{
txt.WriteLine("Паралелограм:");
txt.WriteLine("AB=" + Convert.ToString(Math.Round(ab, 3)));
txt.WriteLine("BC=" + Convert.ToString(Math.Round(bc, 3)));
txt.WriteLine("CD=" + Convert.ToString(Math.Round(cd, 3)));
txt.WriteLine("DA=" + Convert.ToString(Math.Round(da, 3)));
txt.WriteLine("AC=" + Convert.ToString(Math.Round(ac, 3)));
txt.WriteLine("BD=" + Convert.ToString(Math.Round(bd, 3)));
txt.WriteLine("P=" + Convert.ToString(Math.Round(p, 3)));
txt.WriteLine("S=" + Convert.ToString(Math.Round(s, 3)));
}
}
}
if (comboBox1.SelectedIndex == 1)
{
if ((y2 - y1) != (y3 - y4) || x1!=x2 || x3!=x4)
MessageBox.Show("Введіть вірні дані");
else
{
ab = Math.Sqrt((Math.Pow(x2 - x1, 2)) + (Math.Pow(y2 - y1, 2)));
bc = Math.Sqrt((Math.Pow(x3 - x2, 2)) + (Math.Pow(y3 - y2, 2)));
cd = Math.Sqrt((Math.Pow(x4 - x3, 2)) + (Math.Pow(y4 - y3, 2)));
da = Math.Sqrt((Math.Pow(x1 - x4, 2)) + (Math.Pow(y1 - y4, 2)));
ac = Math.Sqrt((Math.Pow(x3 - x1, 2)) + (Math.Pow(y3 - y1, 2)));
bd = Math.Sqrt((Math.Pow(x4 - x2, 2)) + (Math.Pow(y4 - y2, 2)));
p = 2 * (ab + bc);
s = ab * bd;
textBox9.Text = Convert.ToString(Math.Round(ab, 3));
textBox10.Text = Convert.ToString(Math.Round(bc, 3));
textBox11.Text = Convert.ToString(Math.Round(cd, 3));
textBox12.Text = Convert.ToString(Math.Round(da, 3));
textBox13.Text = Convert.ToString(Math.Round(ac, 3));
textBox14.Text = Convert.ToString(Math.Round(bd, 3));
textBox15.Text = Convert.ToString(Math.Round(p, 3));
textBox16.Text = Convert.ToString(Math.Round(s, 3));
using (var txt = File.AppendText(@"figyru.txt"))
{
txt.WriteLine("Прямокутник:");
txt.WriteLine("AB=" + Convert.ToString(Math.Round(ab, 3)));
txt.WriteLine("BC=" + Convert.ToString(Math.Round(bc, 3)));
txt.WriteLine("CD=" + Convert.ToString(Math.Round(cd, 3)));
txt.WriteLine("DA=" + Convert.ToString(Math.Round(da, 3)));
txt.WriteLine("AC=" + Convert.ToString(Math.Round(ac, 3)));
txt.WriteLine("BD=" + Convert.ToString(Math.Round(bd, 3)));
txt.WriteLine("P=" + Convert.ToString(Math.Round(p, 3)));
txt.WriteLine("S=" + Convert.ToString(Math.Round(s, 3)));
}
}
}
if (comboBox1.SelectedIndex == 2)
{
if (textBox17.Text == "")
MessageBox.Show("Введіть дані");
else
h = Convert.ToDouble(textBox17.Text);
if ((y1 - y2) != (y4 - y3) || x1!=x3 || y2!=y4)
MessageBox.Show("Введіть вірні дані");
else
{
ab = Math.Sqrt((Math.Pow(x2 - x1, 2)) + (Math.Pow(y2 - y1, 2)));
bc = Math.Sqrt((Math.Pow(x3 - x2, 2)) + (Math.Pow(y3 - y2, 2)));
cd = Math.Sqrt((Math.Pow(x4 - x3, 2)) + (Math.Pow(y4 - y3, 2)));
da = Math.Sqrt((Math.Pow(x1 - x4, 2)) + (Math.Pow(y1 - y4, 2)));
ac = Math.Sqrt((Math.Pow(x3 - x1, 2)) + (Math.Pow(y3 - y1, 2)));
bd = Math.Sqrt((Math.Pow(x4 - x2, 2)) + (Math.Pow(y4 - y2, 2)));
p = 4 * ab;
s = ab * h;
textBox9.Text = Convert.ToString(Math.Round(ab, 3));
textBox10.Text = Convert.ToString(Math.Round(bc, 3));
textBox11.Text = Convert.ToString(Math.Round(cd, 3));
textBox12.Text = Convert.ToString(Math.Round(da, 3));
textBox13.Text = Convert.ToString(Math.Round(ac, 3));
textBox14.Text = Convert.ToString(Math.Round(bd, 3));
textBox15.Text = Convert.ToString(Math.Round(p, 3));
textBox16.Text = Convert.ToString(Math.Round(s, 3));
using (var txt = File.AppendText(@"figyru.txt"))
{
txt.WriteLine("Ромб:");
txt.WriteLine("AB=" + Convert.ToString(Math.Round(ab, 3)));
txt.WriteLine("BC=" + Convert.ToString(Math.Round(bc, 3)));
txt.WriteLine("CD=" + Convert.ToString(Math.Round(cd, 3)));
txt.WriteLine("DA=" + Convert.ToString(Math.Round(da, 3)));
txt.WriteLine("AC=" + Convert.ToString(Math.Round(ac, 3)));
txt.WriteLine("BD=" + Convert.ToString(Math.Round(bd, 3)));
txt.WriteLine("P=" + Convert.ToString(Math.Round(p, 3)));
txt.WriteLine("S=" + Convert.ToString(Math.Round(s, 3)));
}
}
}
if (comboBox1.SelectedIndex == 3)
{
if ((y2 - y1) != (y3 - y4) || (x1 - x4) != (x2 - x3))
MessageBox.Show("Введіть вірні дані");
else
{
ab = Math.Sqrt((Math.Pow(x2 - x1, 2)) + (Math.Pow(y2 - y1, 2)));
bc = Math.Sqrt((Math.Pow(x3 - x2, 2)) + (Math.Pow(y3 - y2, 2)));
cd = Math.Sqrt((Math.Pow(x4 - x3, 2)) + (Math.Pow(y4 - y3, 2)));
da = Math.Sqrt((Math.Pow(x1 - x4, 2)) + (Math.Pow(y1 - y4, 2)));
ac = Math.Sqrt((Math.Pow(x3 - x1, 2)) + (Math.Pow(y3 - y1, 2)));
bd = Math.Sqrt((Math.Pow(x4 - x2, 2)) + (Math.Pow(y4 - y2, 2)));
p = 4 * ab;
s = ab *ab;
textBox9.Text = Convert.ToString(Math.Round(ab, 3));
textBox10.Text = Convert.ToString(Math.Round(bc, 3));
textBox11.Text = Convert.ToString(Math.Round(cd, 3));
textBox12.Text = Convert.ToString(Math.Round(da, 3));
textBox13.Text = Convert.ToString(Math.Round(ac, 3));
textBox14.Text = Convert.ToString(Math.Round(bd, 3));
textBox15.Text = Convert.ToString(Math.Round(p, 3));
textBox16.Text = Convert.ToString(Math.Round(s, 3));
using (var txt = File.AppendText(@"figyru.txt"))
{
txt.WriteLine("Квадрат:");
txt.WriteLine("AB=" + Convert.ToString(Math.Round(ab,3)));
txt.WriteLine("BC=" + Convert.ToString(Math.Round(bc,3)));
txt.WriteLine("CD=" + Convert.ToString(Math.Round(cd,3)));
txt.WriteLine("DA=" + Convert.ToString(Math.Round(da,3)));
txt.WriteLine("AC=" + Convert.ToString(Math.Round(ac,3)));
txt.WriteLine("BD=" + Convert.ToString(Math.Round(bd,3)));
txt.WriteLine("P=" + Convert.ToString(Math.Round(p,3)));
txt.WriteLine("S=" + Convert.ToString(Math.Round(s,3)));
}
}
}
}