0% found this document useful (0 votes)
38 views3 pages

RESUMEN

This document defines a class called LIBRO to manage book inventory. The LIBRO class contains an array of LIBROS structs that hold book details like name, author, price. The class contains methods to calculate total cost, inventory count, find most expensive book, and sort books by price. The main method initializes a LIBRO object, calls the methods to output results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

RESUMEN

This document defines a class called LIBRO to manage book inventory. The LIBRO class contains an array of LIBROS structs that hold book details like name, author, price. The class contains methods to calculate total cost, inventory count, find most expensive book, and sort books by price. The main method initializes a LIBRO object, calls the methods to output results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

RESUMEN

CLASE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp90
{
public struct LIBROS
{
public string nombreli,autor;
public int cinvent;
public double precio;
public int CANT;
public LIBROS( string a,string b,int c,double d,int E)
{
nombreli = a;autor = b;
cinvent = c;
precio = d;
CANT = E;

public void REPORTE()

{
Console.WriteLine(" {0} {1} {2} {3} ", nombreli, autor, cinvent,
precio, CANT);
}

}
class LIBRO
{
LIBROS[] LI;
int I;
public LIBRO()
{
Console.WriteLine("CUANTOS LIBRO DESEA CONSULTAR");
int CANTLI = int.Parse(Console.ReadLine());
LI = new LIBROS[CANTLI];
for(I=0;I<LI.Length;I=I+1)
{
Console.WriteLine("NOMBRE");
string NOM = Console.ReadLine();
Console.WriteLine("AUTOR");
string AUT = Console.ReadLine();
Console.WriteLine("CANTIDAD DE INVENTARIO");
int CANTIN = int.Parse(Console.ReadLine());
Console.WriteLine("PRECIO");
double PREC = double.Parse(Console.ReadLine());

Console.WriteLine("CUANTAS UNIDADES DESEA LLEVAR");


int UNI = int.Parse(Console.ReadLine());
LI[I] = new LIBROS(NOM, AUT, CANTIN, PREC,UNI);

}
}

public double CALMONTOTOT()


{
double MONTOTOT = 0;

for(I=0;I<LI.Length;I=I+1)
{
MONTOTOT = MONTOTOT + LI[I].precio * LI[I].CANT;
}

return MONTOTOT;
}

public int CANTIDADINVENT()


{
int CAT = 0;
for(I=0;I<LI.Length;I=I+1)
{
CAT = CAT + LI[I].cinvent;
}

return CAT;
}

public void CALMAYORPRE()


{
Double MAYORPRE = LI[0].precio;

for(int I=0;I<LI.Length;I=I+1)
{
if(LI[I].precio>MAYORPRE)
{
MAYORPRE = LI[I].precio;
}
}
for (int I = 0; I < LI.Length; I = I + 1)
{
if (LI[I].precio == MAYORPRE)
{
MAYORPRE = LI[I].precio;
Console.WriteLine("EL LIBRO CON MAYOR PRECIO ES {0}",
LI[I].nombreli);
}
}
}

public void ORDENAR_SEGUN_PRECIO()


{
LIBROS AUX;

for(I=0;I<LI.Length-1;I=I+1)
{
for(int J=I+1;J<LI.Length;J=J+1)
{
if(LI[I].precio>LI[J].precio)
{
AUX = LI[I];
LI[I] = LI[J];
LI[J] = AUX;
}
}
}

for(I=0;I<LI.Length;I=I+1)
{
LI[I].REPORTE();
}
}
}
}

MAIN

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp90
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("BIENVENIDO AL SISTEMA DE LIBRERIA");
LIBRO L = new LIBRO();
Console.WriteLine("MONTO TOTAL {0} ", L.CALMONTOTOT());
Console.WriteLine("CANTIDAD DE INVENTARIO {0} ",L.CANTIDADINVENT());
L.CALMAYORPRE();
L.ORDENAR_SEGUN_PRECIO();
Console.ReadKey();
}
}
}

You might also like