-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
130 lines (112 loc) · 4.88 KB
/
Program.cs
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
using System;
namespace Teorema_Pitagoras
{
class Program
{
static void Main(string[] args)
{
Apariencia();
PedirCalculo();
Console.ReadKey();
}
static void PedirCalculo()
{
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Que quieres calcular: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine("Cateto/Hipotenusa");
string input = Console.ReadLine();
if (input == "Cateto")
{
Cateto();
PedirCalculo();
} else if (input == "Hipotenusa")
{
Hipotenusa();
PedirCalculo();
} else
{
Console.WriteLine("No te entiendo, repite por favor:");
PedirCalculo();
}
}
static void Cateto()
{
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Longitud hipotenusa: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
float longH = (float)Convert.ToDouble(Console.ReadLine());
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Longitud cateto: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
float longC = (float)Convert.ToDouble(Console.ReadLine());
Console.ForegroundColor = System.ConsoleColor.Green;
double longC2 = CalcularCateto(longH, longC);
Console.Write("Cateto mide: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(longC2);
Console.ForegroundColor = System.ConsoleColor.Green;
double P = longH + longC + longC2;
Console.Write("Perímetro: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(P);
Console.ForegroundColor = System.ConsoleColor.Green;
double A = (longC * longC2)/2;
Console.Write("Area: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(A);
Console.ForegroundColor = System.ConsoleColor.DarkBlue;
Console.WriteLine("----------------------------------------");
}
static double CalcularCateto(float longH, float longC)
{
double longC2 = MathF.Sqrt(MathF.Pow((float)longH, 2) - MathF.Pow((float)longC, 2));
return longC2;
}
static void Hipotenusa()
{
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Cateto 1: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
float _longC1 = (float)Convert.ToDouble(Console.ReadLine());
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Cateto 2: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
float _longC2 = (float)Convert.ToDouble(Console.ReadLine());
double _longH = CalcularHipotenusa(_longC1, _longC2);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Hipotenusa: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(_longH);
double P = _longC1 + _longC2 + _longH;
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Perímetro: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(P);
double A = (_longC1 * _longC2)/2;
Console.ForegroundColor = System.ConsoleColor.Green;
Console.Write("Area: ");
Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
Console.WriteLine(A);
Console.ForegroundColor = System.ConsoleColor.DarkBlue;
Console.WriteLine("----------------------------------------");
}
static double CalcularHipotenusa(float longC1, float longC2)
{
double longH = MathF.Sqrt(MathF.Pow(longC1, 2) + MathF.Pow(longC2, 2));
return longH;
}
static void Apariencia ()
{
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("----------------JatoMixo----------------");
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("----------Teorema de Pitágoras----------");
Console.ForegroundColor = System.ConsoleColor.DarkBlue;
Console.WriteLine("----------------------------------------");
Console.Title = "JatoMixo: Teorema de Pitágoras";
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WindowWidth = 40;
}
}
}