jueves, abril 06, 2006

PEMEX vs USA


Hacer un programa que calcule el costo por litro de gasolina comparando la cantidad en litros.

Se Insertaran los valores del costo por litro de PEMEX y el costo por Galon en USA. Ademas se tendra que insertar el precio del Dollar.

El calculo se realizara a partir del total de consumo. El cual mostrara la cantidad de combustible despachado en litros. Esto nos mostrara cual de los dos combustibles nos da mas litros por peso.

martes, abril 04, 2006

Convertidor Numerico a Texto (programa)

Module Module1
'uno dos tres cuatro cinco seis site ocho nueve diez
'once doce trece catorce quince diesiseis diesisiete diesiocho diesinueve
'veinte veintiuno veintidos veintitres veinticuatro veinticinco veintiseis veintisiete veintiocho veintinueve

'treinta treinta y uno treinta y cuatro treinta y cinco treinta y siete treinta y ocho treinta y nueve
'cuarenta cuarenta y uno, cuarenta y...
'cincuenta
'sesenta, setenta, ochenta, noventa cien
Sub Main()
Dim Numero As String
Dim tam As Integer
Dim unidad As String, decen As String, centena As String, millar As String
Dim textoNum As String
Dim Miles() As String = {"", "mil", "dos mil", "tres mil", "cuatro mil", "cinco mil", "seis mil", "siete mil", "ocho mil", "nueve mil"}
Dim Centenas() As String = {"", "cien", "docientos", "trecientos", "cuatrocientos", "quinientos", "seiscientos", "setecientos", "ochocientos", "novecientos"}
Dim Decimales() As String = {"", "", "", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa"}

Dim CeroVeinte() As String = {"", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", _
"once", "doce", "trece", "catorce", "quince", "dieciseis", "diecisiete", "dieciocho", "diecinueve", _
"veinte", "veintiuno", "veintidos", "veintitres", "veinticuatro", "veinticinco", "veintiseis", _
"veintisiete", "veintiocho", "veintinueve"}

Do

Numero = Console.ReadLine()
tam = Numero.Length
'Regresa la longitud de la cadena

If tam = 1 Then
unidad = GetChar(Numero, 1)
End If

If tam = 2 Then
decen = GetChar(Numero, 1)
unidad = GetChar(Numero, 2)
ElseIf tam = 3 Then
centena = GetChar(Numero, 1)
decen = GetChar(Numero, 2)
unidad = GetChar(Numero, 3)

ElseIf tam = 4 Then
millar = GetChar(Numero, 1)
centena = GetChar(Numero, 2)
decen = GetChar(Numero, 3)
unidad = GetChar(Numero, 4)
End If

'***************************************** 1000-9000
If tam > 3 Then
'Console.WriteLine("{0}", Miles(CInt(millar)))
textoNum += Miles(CInt(millar)) & " "
End If

'***************************************** 200-900

If tam >= 3 And centena > 1 Then
'Console.WriteLine("{0}", Centenas(CInt(centena)))
textoNum += Centenas(CInt(centena)) & " "
End If

'************************************** 100to
If tam >= 3 And centena = 1 And unidad = 0 Then
'Console.WriteLine("{0}", Centenas(CInt(centena)))
textoNum += Centenas(CInt(centena)) & " "
End If

If tam >= 3 And centena = 1 And unidad > 0 Then
'Console.WriteLine("{0}", Centenas(CInt(centena)))
textoNum += Centenas(CInt(centena)) & "to "
End If

'********************************************** 30-99
If CInt(Right(Numero, 2)) > 29 Then
'Console.WriteLine("{0}", Decimales(CInt(decen)))
textoNum += Decimales(CInt(decen)) & " "
If CInt(unidad) > 0 Then
'Console.WriteLine("y {0}", CeroVeinte(CInt(unidad)))
textoNum += CeroVeinte(CInt(unidad)) & " "
End If
End If
'************************************* 0-29
If CInt(Right(Numero, 2)) < 30 Then
'Console.WriteLine("{0}", CeroVeinte(CInt(Right(Numero, 2))))
textoNum += CeroVeinte(CInt(Right(Numero, 2))) & " "
End If

If tam = 1 And unidad = 0 Then
textoNum = "cero"
End If

Console.WriteLine(textoNum)
textoNum = ""
Loop While CInt(Numero) < 10000

End Sub

End Module