using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ventas_Mes
{
class Program
{
static void Main(string[] args)
{
double venta,total;
Arreglo Ventas = new Arreglo(12);
int mes, resp,menorIndice;
do
{
NoMes:
Console.Write("\nIngresa numero de mes: ");
mes = int.Parse(Console.ReadLine());
if (mes > 12 mes < 1)
{
Console.WriteLine("Mes incorrecto");
goto NoMes;
}
else
{
Console.Write("Ingresa la venta del mes:");
venta = double.Parse(Console.ReadLine());
Ventas.sumaVentas(mes - 1, venta);
if (venta < Ventas.obtenerCantidad(mes - 1))
{
Ventas.asignarCantidad(mes - 1, venta);
}
}
Console.Write("Desea capturar otra venta? (1= Si, 0= No):");
resp = int.Parse(Console.ReadLine());
}
while (resp == 1);
total = 0;
for (int i = 0; i < 12; i++)
{
total = total + Ventas.obtenerDato(i);
Console.WriteLine("Mes: {0}", i + 1);
Console.WriteLine("Venta total del mes= {0}\n", Ventas.obtenerDato(i));
}
menorIndice=Ventas.ventaMenor();
Console.WriteLine("\nLa venta anual es: {0}", total);
Console.WriteLine("La venta menor mensual del año fue de: {0}\n", Ventas.obtenerDato(menorIndice));
for (int i = 0; i < 12; i++)
{
if (Ventas.obtenerCantidad(i)<50000)
Console.WriteLine("La venta del mes {0} es de: {1}", i+1, Ventas.obtenerDato(i));
}
Console.ReadLine();
}
}
}
Class Arreglo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ventas_Mes
{
class Arreglo
{
double[] vector;
double[] cantidades;
double menorVenta;
int i=0;
int indiceMen= 0;
public Arreglo()
{
vector = new double[10];
}
public Arreglo(int n)
{
vector = new double[n];
cantidades = new double[12] { 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000 };
}
public void asignarDato(int j, double dato)
{
vector[j] = dato;
}
public void asignarCantidad(int j, double dato)
{
cantidades[j] = dato;
}
public double obtenerCantidad(int j)
{
return cantidades[j];
}
public void sumaVentas(int j, double dato)
{
vector[j] = vector[j] + dato;
}
public double obtenerDato(int j)
{
return vector[j];
}
public int ventaMenor()
{
menorVenta = vector[0];
indiceMen = 0;
for (i = 1; i < 12; i++)
{
if (vector[i] <>0)
{
menorVenta = vector[i];
indiceMen = i;
}
}
return indiceMen;
}
}
}
No hay comentarios:
Publicar un comentario