|
@@ -11,12 +11,12 @@ namespace Exam
|
|
|
public double diameter, thickness;
|
|
|
public bool isDefective, isReinforced;
|
|
|
public bool checkLength, checkDiameter, checkThickness;
|
|
|
+ public double weight;
|
|
|
}
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
{
|
|
|
- Tubes[] tube = new Tubes[0];
|
|
|
- tube = ReadData.Read("data.txt");
|
|
|
+ Tubes[] tube = ReadData.Read("data.txt");
|
|
|
|
|
|
double[] diameters = new double[] { 20.000, 25.000, 32.000, 40.000, 50.000, 63.000 };
|
|
|
|
|
@@ -57,8 +57,6 @@ namespace Exam
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int count10 = 0, count16 = 0, count20 = 0, count25 = 0;
|
|
|
-
|
|
|
for (int i = 0; i < tube.Length; i++)
|
|
|
{
|
|
|
if (!tube[i].isDefective)
|
|
@@ -66,7 +64,6 @@ namespace Exam
|
|
|
switch (tube[i].name)
|
|
|
{
|
|
|
case "PN10":
|
|
|
- count10++;
|
|
|
startRange = tube[i].diameter / 100.0 * 10.0;
|
|
|
endRange = tube[i].diameter / 100.0 * 11.0;
|
|
|
|
|
@@ -77,7 +74,6 @@ namespace Exam
|
|
|
}
|
|
|
break;
|
|
|
case "PN16":
|
|
|
- count16++;
|
|
|
startRange = tube[i].diameter / 100.0 * 13.5;
|
|
|
endRange = tube[i].diameter / 100.0 * 14.0;
|
|
|
|
|
@@ -88,7 +84,6 @@ namespace Exam
|
|
|
}
|
|
|
break;
|
|
|
case "PN20":
|
|
|
- count20++;
|
|
|
startRange = tube[i].diameter / 100.0 * 16.5;
|
|
|
endRange = tube[i].diameter / 100.0 * 17.0;
|
|
|
|
|
@@ -99,7 +94,6 @@ namespace Exam
|
|
|
}
|
|
|
break;
|
|
|
case "PN25":
|
|
|
- count25++;
|
|
|
startRange = tube[i].diameter / 100.0 * 16.5;
|
|
|
endRange = tube[i].diameter / 100.0 * 17.0;
|
|
|
|
|
@@ -118,6 +112,35 @@ namespace Exam
|
|
|
Console.WriteLine($"PN20 - {getPercent(tube, "PN20")}");
|
|
|
Console.WriteLine($"PN25 - {getPercent(tube, "PN25")}");
|
|
|
|
|
|
+ double p = 0;
|
|
|
+
|
|
|
+ for (int i = 0; i < tube.Length; i++)
|
|
|
+ {
|
|
|
+ if (tube[i].isReinforced)
|
|
|
+ {
|
|
|
+ p = 1240;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p = 910;
|
|
|
+ }
|
|
|
+ tube[i].weight = p * tube[i].thickness * Math.PI * (tube[i].diameter - tube[i].thickness);
|
|
|
+ }
|
|
|
+
|
|
|
+ double totalWeight = 0, totalDef = 0, totalNotDef = 0;
|
|
|
+ for (int i = 0; i < tube.Length; i++)
|
|
|
+ {
|
|
|
+ totalWeight += tube[i].weight;
|
|
|
+ if (tube[i].isDefective)
|
|
|
+ {
|
|
|
+ totalDef += tube[i].weight;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ totalNotDef += tube[i].weight;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for (int i = 0; i < tube.Length; i++)
|
|
|
{
|
|
|
if (!tube[i].isDefective)
|
|
@@ -146,7 +169,7 @@ namespace Exam
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- percent = (countDef * 100) / (countNotDef + countDef);
|
|
|
+ percent = (countDef * 100) / (countDef + countNotDef);
|
|
|
return percent;
|
|
|
}
|
|
|
}
|