Académique Documents
Professionnel Documents
Culture Documents
Realizar lo siguiente:
1. Programa que calcule el precio total a pagar de tres materiales.
Primero se ingresará por teclado las cantidades y precio de tres
materiales, almacenándolos en dos arreglos unidimensionales.
Posteriormente se obtendrá los precios parciales almacenándolos en
otro arreglo unidimensional y finalmente se obtendrá el precio toral.
Solución
Console.WriteLine();
Console.ReadLine();
}
}
Programa que lea dos arreglos de 5 números cada uno (A y B) y por medio
de un menú de opciones calcule:
Menu
a. La suma del arreglo A y B
b. 2A-3B
c. Raíz cuadrada (A) + B3
Elegir opción:
Elemplo:
Ingrese datos del arreglo A
A[0]: 2
A[1]: 10
A[2]: 5
A[3]: 11
A[4]: 0
Ingrese datos del arreglo B
B[0]: 8
B[1]: 6
B[2]: 1
B[3]: 4
B[4]: 2
Menu
a. La suma del arreglo A y B
b. 2A-3B
c. Raíz cuadrada (A) + B3
Elegir opción: a
S[0]:10
S[1]: 16
S[2]: 5
S[3]: 15
S[4]: 2
solucion
class Program
{
static void Main(string[] args)
{
Console.WriteLine("ARREGLO 1");
float[] array1 = new float[5];
for (int x = 0; x < 5; x++)
{
Console.Write("Ingrese termino[" + (x + 1) + "]: ");
array1[x] = float.Parse(Console.ReadLine());
}
Console.WriteLine("");
Console.WriteLine("ARREGLO 2");
float[] array2 = new float[5];
for (int x = 0; x < 5; x++)
{
Console.Write("Ingrese termino[" + (x + 1) + "]: ");
array2[x] = float.Parse(Console.ReadLine());
}
Console.WriteLine("");
Console.WriteLine("ARREGLO 1");
for (int x = 0; x < 5; x++)
{
Console.WriteLine(array1[x]);
}
Console.WriteLine("");
Console.WriteLine("ARREGLO 2");
for (int x = 0; x < 5; x++)
{
Console.WriteLine(array2[x]);
}
Console.WriteLine("");
Console.WriteLine("\tMENU");
Console.WriteLine("a: La suma del arreglo A y B");
Console.WriteLine("b: 2A-3B");
Console.WriteLine("c: Raiz cuadrada de A mas B al cubo");
Console.WriteLine("");
char m;
Console.Write("Elegir opción:");
m = char.Parse(Console.ReadLine());
switch (m)
{
case 'a':
case 'A':
for (int x = 0; x < 5; x++)
{
Console.WriteLine(array1[x] + array2[x]);
}
break;
case 'b':
case 'B':
for (int x = 0; x < 5; x++)
{
Console.WriteLine((2 * array1[x]) - (3 * array2[x]));
}
break;
case 'c':
case 'C':
for (int x = 0; x < 5; x++)
{
Console.WriteLine(Math.Sqrt(array1[x]) + Math.Pow(array2[x],
3));
}
break;
default:
Console.WriteLine("Error! Elija opción de a, b, c");
break;
}
Console.ReadLine();
}
}