Vous êtes sur la page 1sur 5

PRACTICA CALIFICADA PROGRAMACION DIGITAL

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.

Material Cantidad Precio (S/.) Precio Parcial


1 100 150 15000
2 20 80 1600
3 12 4 48
Precio Total 16648

Solución

static void Main(string[] args)


{
float suma = 0;
Console.WriteLine("INGRESE CANTIDAD DE MATERIALES");
Console.WriteLine();
float[] array1 = new float[3];
for (int x = 0; x < 3; x++)
{
Console.Write("Ingrese cantidad de material[" + (x + 1) + "]: ");
array1[x] = float.Parse(Console.ReadLine());
}
Console.WriteLine("");
Console.WriteLine("INGRESE PRECIO DE MATERIALES");
Console.WriteLine();
float[] array2 = new float[3];
for (int x = 0; x < 3; x++)
{
Console.Write("Ingrese precio de material[" + (x + 1) + "]: ");
array2[x] = float.Parse(Console.ReadLine());
}

float[] array3 = new float[3];


for (int x = 0; x < 3; x++)
{

array3[x] = array1[x] * array2[x];


suma = suma + array3[x];
}

Console.WriteLine();

Console.WriteLine("MATERIAL\t CANTIDAD \t PRECIO \t PRECIO PARCIAL");


for (int x = 0; x < 3; x++)
{
Console.Write(x+1 + "\t \t");
Console.Write(array1[x] + "\t \t");
Console.Write(array2[x] + "\t \t");
Console.WriteLine(array3[x]);

Console.WriteLine(" \t \t \t \t PRECIO TOTAL \t" + suma);

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();
}
}

Vous aimerez peut-être aussi