Êîíñîëüíîå ïðèëîæåíèå äëÿ ðàñ÷åòà ìàññû èçäåëèé
Ëèñòèíã 76.1. Ïðîåêò Part 3. Ôàéë Program.cs.
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
namespace ConsoleApplication1
{
class Program
{
//Ìû íà÷èíàåì çàïèñûâàòü êîä:
double d, H, s; double pi = Math.PI;
double rho=7850; //: for steel.
double A, V, m, D;
double Area() //Ïëîùàäü ïîâåðõíîñòè äåòàëè:
{
double A1, A2;
A1=Area1(); A2=Area2(); A=A1+A2;
return A;
}
double Volume() //Îáúåì äåòàëè:
{
A=Area(); V=A*s; return V;
}
double mass() //Ìàññà äåòàëè:
{
Console.Write("Part diameter, mm, d =");
d = Convert.ToDouble(Console.ReadLine());
Console.Write("Part heigth, mm, H =");
H = Convert.ToDouble(Console.ReadLine());
Console.Write("Part thickness, mm, s =");
s = Convert.ToDouble(Console.ReadLine());
A=Area();
V=Volume(); //mm*mm*mm
m=V*rho*1.0e-9; // kg
Console.WriteLine("");//Ïðîáåëüíàÿ ñòðîêà.
//Âûâîä ïëîùàäè:
Console.Write("Part area, mm*mm, A =");
Console.WriteLine(A);
//Âûâîä îáúåìà:
Console.Write("Part volume, mm*mm*mm, V =");
Console.WriteLine(V);
//Âûâîä ìàññû:
Console.Write("Part mass for steel,kg,m=");
Console.WriteLine(m);
return m;
}
double DBlank() //Äèàìåòð ïëîñêîé çàãîòîâêè:
{
A=Area();
D=Math.Sqrt(4*A/pi);
//Âûâîä äèàìåòðà çàãîòîâêè:
Console.Write("Blank diameter, mm, D =");
Console.WriteLine(D);
Console.WriteLine("");//Ïðîáåëüíàÿ ñòðîêà.
return D;
}
double Area1() //Ïëîùàäü êðóãà:
{
double A1; double Rn; Rn=H;
A1=pi*(d-2*Rn)*(d-2*Rn)/4;
return A1; //mm*mm
}
double Area2() //Ïëîùàäü òîðà:
{
double A2; double Rn; Rn=H;
A2=pi*(Rn-s/2)*(2*(Rn-s/2)+pi*(d-2*Rn)/2);
return A2; //mm*mm
}
//Ìû çàêîí÷èëè íàïèñàíèå êîäà.
static void Main(string[] args)
{
//Ìû íà÷èíàåì çàïèñûâàòü êîä:
//Ñîçäàòü îáúåêò-äåòàëü Part3:
Program Part3 = new Program();
//Íà îáúåêòå Part3 ðàññ÷èòàòü ïëîùàäü:
Part3.Area();
//Íà îáúåêòå Part3 ðàññ÷èòàòü îáúåì:
Part3.Volume();
// Íà îáúåêòå Part3 ðàññ÷èòàòü ìàññó:
Part3.mass();
//Íà îáúåêòå Part3 ðàññ÷èòàòü çàãîòîâêó:
Part3.DBlank();
//Ìû çàêîí÷èëè íàïèñàíèå êîäà.
}
}
}