Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: NetStorm en 16 Mayo 2009, 04:01 am



Título: Ayudas o sugerencias - programa signo zodiaco
Publicado por: NetStorm en 16 Mayo 2009, 04:01 am
Hola chicos he empezado a estudiar VB.NET, y resulta que termine los ejercicios de la clase entonces el profesor con cara de condenado me dijo: "Quiero que hagas un programa que muestre el horoscopo de una persona ingresando solo el dia y mes de nacimiento, aclaro que esto lo haciendo en aplicaciones para consola este es mi avance trate de hacerlo con IF, pero cuando mire el detalle d la fecha de nacimiento ... OH DIOS!!!, necesito sugerencias o como podría hacerlo, haber echenme una manito, porque recien inicio en esto

Código:
Imports System.Console
'PROGRAMA QUE MUESTRA EL SIGNO ZODIACAL DEL USUARIO CON EL DIA Y AÑO DE NACIMIENTO
Module Module12
    Sub main()
        Const ener As String = "Enero"
        Const febre As String = "Febrero"
        Const mar As String = "Marzo"
        Const abr As String = "Abril"
        Const mayo As String = "Mayo"
        Const jun As String = "Junio"
        Const jul As String = "Julio"
        Const agost As String = "Agosto"
        Const septi As String = "Septiembre"
        Const octub As String = "Octubre"
        Const novi As String = "Noviembre"
        Const dici As String = "Diciembre"

        Dim mes As String
        Dim dia As Integer

        WriteLine("Por favor, ingrese el mes de nacimiento")
        mes = ReadLine()
        WriteLine("Por favor, ingrese el día de nacimiento")
        dia = ReadLine()
        If mes = ener And dia < 20 < 18 Then


        End If
    End Sub
End Module

... Agradecido desde ya. Salu2 para todos.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 16 Mayo 2009, 04:16 am
Aver si te sirve este code creado por (¯`·.¸º|- POLIFORMIC -|º¸.·´¯)

Código
  1. /*ingrese dia y mes de nacimiento, luego se debe determinar
  2. su signo sodiacal*/
  3. #include<iostream.h>
  4. #include<conio.h>
  5. int dia, mes;
  6. void main(){
  7. cout<<" TU SIGNO ZODIACAL ";
  8. cout<<"\n\r ---------------";
  9. cout<<"\n\r Ingrese el Dia y mes de nacimiento "; cin>>dia>>mes;
  10. switch(mes){
  11.      case 1: if(dia<21) cout<<"CAPRICORNIO";
  12.              else       cout<<"ACUARIO"; break;
  13.      case 2: if(dia<20) cout<<"ACUARIO";
  14.              else       cout<<"PICIS"; break;
  15.      case 3: if(dia<21) cout<<"PICIS";
  16.              else       cout<<"ARIES"; break;
  17.      case 4: if(dia<21) cout<<"ARIES";
  18.              else       cout<<"TAURO"; break;
  19.      case 5: if(dia<21) cout<<"TAURO";
  20.              else       cout<<"GEMINIS"; break;
  21.      case 6: if(dia<22) cout<<"GEMINIS";
  22.              else       cout<<"CANCER"; break;
  23.      case 7: if(dia<23) cout<<"CANCER";
  24.              else       cout<<"LEO"; break;
  25.      case 8: if(dia<23) cout<<"LEO";
  26.              else       cout<<"VIRGO"; break;
  27.      case 9: if(dia<23) cout<<"VIRGO";
  28.              else       cout<<"LIBRA"; break;
  29.      case 10: if(dia<23) cout<<"LIBRA";
  30.              else       cout<<"ESCORPIO"; break;
  31.      case 11: if(dia<22) cout<<"ESCORPIO";
  32.              else       cout<<"SAGITARIO"; break;
  33.      case 12: if(dia<22) cout<<"SAGITARIO";
  34.              else       cout<<"CAPRICORNIO"; break;
  35.   default:cout<<"\n\r Mes y Dia son incorrectos";
  36.   }
  37.   getch();
  38. }
  39.  


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Shell Root en 16 Mayo 2009, 07:00 am
Servira de Guia, porque eso no es VB... xD

Saludos!!!


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 16 Mayo 2009, 19:16 pm
int dia, mes; == Dim dia as integer
                      Dim mes as integer
switch(mes)== Select case mes

cout<<"\n\r Ingrese el Dia y mes de nacimiento "; cin>>dia>>mes; == Inputbox



Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Jorgitoh en 17 Mayo 2009, 04:18 am
Hola buenas noches. Como primer instancia tienes que hacer el ingreso de datos que sino me equivoco el tuyo esta mas que bien:

        Dim mes As String
        Dim dia As Integer

        WriteLine("Por favor, ingrese el mes de nacimiento")
        mes = ReadLine()
        WriteLine("Por favor, ingrese el día de nacimiento")
        dia = ReadLine()

Al menos en C# ( desconozco VB pero debe ser lo mismo ) puedes pedir directamente la fecha con cierto formato y trabajar con el tipo de dato DateTime, pero de todos modos eso es solo un detalle que no afectaria el funcionamiento del programa.

Como segundo paso debes hacer un switch tal cual esta explicado en el ejemplo que te pusieron mas arriba. Seguramente conoces las estructuras de VB por lo cual lo unico que tienes que hacer es convertir ese codigo de C a VB. El cual su sintaxis no seria nada mas complicado que:

Switch ( mes )
Case ( 1 - 12 )
If
Else

Lo que hace este switch es simple. Primero realiza un case para cada mes del año y luego "segmenta" por asi decirlo los dias con el If. Dejando dentro del If los dias que son menores a 20 / 21 / 22 / 23 ( dependiendo del mes ) al cual se le asigna el signo correspondiente al mes, y luego en el Else toma los dias restantes, asignandole el signo siguiente.

Depende de ti asignar ese signo a una variable o imprimirlo directamente en Consola.

Creo que el ejemplo esta mas que explicado. Solo te faltaria a vos realizar el Switch con la sintaxis de VB, que sino me equivoco en VB se lo conoce como "Select Case".

Saludos.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 17 Mayo 2009, 17:53 pm
Espero que te sirve lo hice a las apuradas en 5 min
Código
  1. Dim dia As Integer
  2. Dim mes As Integer
  3. Dim reponse As Boolean
  4. Private Sub Form_Load()
  5.    dia = InputBox("Ingrese dia", "Signos")
  6.    mes = InputBox("Ingrese mes", "Signos")
  7.    Select Case mes
  8.        Case 1
  9.        If dia < 21 Then
  10.            reponse = MsgBox("CAPRICORNIO", vbOKOnly)
  11.        Else: reponse = MsgBox("ACUARIO", vbOKOnly)
  12.        End If
  13.        Case 2
  14.        If dia < 20 Then
  15.            reponse = MsgBox("ACUARIO", vbOKOnly)
  16.        Else: reponse = MsgBox("PISCIS", vbOKOnly)
  17.        End If
  18.        Case 3
  19.        If dia < 21 Then
  20.            reponse = MsgBox("PISCIS", vbOKOnly)
  21.        Else: reponse = MsgBox("ARIES", vbOKOnly)
  22.        End If
  23.        Case 4
  24.        If dia < 21 Then
  25.            reponse = MsgBox("ARIES", vbOKOnly)
  26.        Else: reponse = MsgBox("TAURO", vbOKOnly)
  27.        End If
  28.        Case 5
  29.        If dia < 21 Then
  30.            reponse = MsgBox("TAURO", vbOKOnly)
  31.        Else: reponse = MsgBox("GEMINIS", vbOKOnly)
  32.        End If
  33.        Case 6
  34.        If dia < 22 Then
  35.            reponse = MsgBox("GEMINIS", vbOKOnly)
  36.        Else: reponse = MsgBox("CANCER", vbOKOnly)
  37.        End If
  38.        Case 7
  39.        If dia < 23 Then
  40.            reponse = MsgBox("CANCER", vbOKOnly)
  41.        Else: reponse = MsgBox("LEO", vbOKOnly)
  42.        End If
  43.        Case 8
  44.        If dia < 23 Then
  45.            reponse = MsgBox("LEO", vbOKOnly)
  46.        Else: reponse = MsgBox("VIRGO", vbOKOnly)
  47.        End If
  48.      Case 9
  49.      If dia < 23 Then
  50.            reponse = MsgBox("VIRGO", vbOKOnly)
  51.        Else: reponse = MsgBox("LIBRA", vbOKOnly)
  52.        End If
  53.      Case 10
  54.      If dia < 23 Then
  55.            reponse = MsgBox("LIBRA", vbOKOnly)
  56.        Else: reponse = MsgBox("ESCORPIO", vbOKOnly)
  57.        End If
  58.      Case 11
  59.      If dia < 22 Then
  60.            reponse = MsgBox("ESCORPIO", vbOKOnly)
  61.        Else: reponse = MsgBox("SAGITARIO", vbOKOnly)
  62.        End If
  63.      Case 12
  64.      If dia < 22 Then
  65.            reponse = MsgBox("SAGITARIO", vbOKOnly)
  66.        Else: reponse = MsgBox("CAPRICORNIO", vbOKOnly)
  67.      End If
  68.  
  69.      Case Else
  70.       reponse = MsgBox("Error")
  71. End Select
  72. End Sub


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: NetStorm en 17 Mayo 2009, 23:35 pm
Waooo, agradezco la última respuesta no tengo conocimiento de "case", pero ahora que veo la estructura aprendo más ... tio sos un grande, sabes la misma noche que escribi mi duda diseñe este algoritmo pero no sé porque no funciona alguien me da el "Hey!!!, fallaste en esto" ??? ... aqui les dejo el code aunque esta larguísimo.

Código:
Imports System.Console

Module Module1

    Sub Main()
        Const january As String = "enero"
        Const febrary As String = "febrero"
        Const march As String = "marzo"
        Const april As String = "abril"
        Const may As String = "mayo"
        Const june As String = "junio"
        Const july As String = "julio"
        Const agost As String = "agosto"
        Const september As String = "setiembre"
        Const october As String = "octubre"
        Const november As String = "noviembre"
        Const december As String = "diciembre"
        Const horoaries As String = "Hoy te ira bien aries"
        Const horotauro As String = "hoy te ira bien tauro"
        Const horogeminis As String = "Hoy te ira bien geminis"
        Const horocancer As String = "Hoy te ira bien cancer"
        Const horoleo As String = "Hoy te ira bien leo"
        Const horovirgo As String = "Hoy te ira bien virgo"
        Const horolibra As String = "Hoy te ira bien libra"
        Const horoescorpio As String = "Hoy te ira bien horoescorpio"
        Const horosagitario As String = "Hoy te ira bien sagitario"
        Const horocapricornio As String = "Hoy te ira bien capricornio"
        Const horoacuario As String = "Hoy te ira bien acuario"
        Const horopiscis As String = "Hoy te ira bien piscis"

        Dim mes As String
        Dim dia As Integer

        WriteLine("por favor ingrese el mes de nacimiento")
        mes = ReadLine()
        WriteLine("Ingrese su dia de nacimiento")
        dia = ReadLine()

        If mes = january And dia > 0 < 20 Then
            WriteLine(horocapricornio & " mucha suerte")
            ReadLine()
        Else
            If mes = january And dia > 19 < 32 Then
                WriteLine(horoacuario & " mucha suerte")
                ReadLine()
            Else
                If mes = febrary And dia > 0 < 19 Then
                    WriteLine(horoacuario & " mucha suerte")
                    ReadLine()
                Else
                    If mes = febrary And dia > 18 < 30 Then
                        WriteLine(horopiscis & " mucha suerte")
                        ReadLine()
                    Else
                        If mes = march And dia > 0 < 20 Then
                            WriteLine(horopiscis & " mucha suerte")
                            ReadLine()
                        Else
                            If mes = march And dia > 18 < 32 Then
                                WriteLine(horoaries & " mucha suerte")
                                ReadLine()
                            Else
                                If mes = april And dia > 0 < 19 Then
                                    WriteLine(horoaries & " mucha suerte")
                                    ReadLine()
                                Else
                                    If mes = april And dia >= 19 < 32 Then
                                        WriteLine(horotauro & " mucha suerte")
                                        ReadLine()
                                    Else
                                        If mes = may And dia >= 1 < 20 Then
                                            WriteLine(horotauro & " mucha suerte")
                                            ReadLine()
                                        Else
                                            If mes = may And dia >= 20 < 32 Then
                                                WriteLine(horogeminis & " mucha suerte")
                                                ReadLine()
                                            Else
                                                If mes = june And dia >= 1 < 21 Then
                                                    WriteLine(horogeminis & " mucha suerte")
                                                    ReadLine()
                                                Else
                                                    If mes = june And dia >= 21 < 32 Then
                                                        WriteLine(horocancer & " mucha suerte")
                                                        ReadLine()
                                                    Else
                                                        If mes = july And dia >= 1 < 22 Then
                                                            WriteLine(horocancer & " mucha suerte")
                                                            ReadLine()
                                                        Else
                                                            If mes = july And dia >= 22 < 32 Then
                                                                WriteLine(horoleo & " mucha suerte")
                                                                ReadLine()
                                                            Else
                                                                If mes = agost And dia >= 1 < 22 Then
                                                                    WriteLine(horoleo & " mucha suerte")
                                                                    ReadLine()
                                                                Else
                                                                    If mes = agost And dia >= 22 < 32 Then
                                                                        WriteLine(horovirgo & " mucha suerte")
                                                                        ReadLine()
                                                                    Else
                                                                        If mes = september And dia >= 1 < 22 Then
                                                                            WriteLine(horovirgo & " mucha suerte")
                                                                            ReadLine()
                                                                        Else
                                                                            If mes = september And dia >= 22 < 32 Then
                                                                                WriteLine(horolibra & " mucha suerte")
                                                                                ReadLine()
                                                                            Else
                                                                                If mes = october And dia >= 1 < 23 Then
                                                                                    WriteLine(horolibra & " mucha suerte")
                                                                                    ReadLine()
                                                                                Else
                                                                                    If mes = october And dia >= 23 < 32 Then
                                                                                        WriteLine(horoescorpio & " mucha suerte")
                                                                                        ReadLine()
                                                                                    Else
                                                                                        If mes = november And dia >= 1 < 21 Then
                                                                                            WriteLine(horoescorpio & " mucha suerte")
                                                                                            ReadLine()
                                                                                        Else
                                                                                            If mes = november And dia >= 21 < 32 Then
                                                                                                WriteLine(horosagitario & " mucha suerte")
                                                                                                ReadLine()
                                                                                            Else
                                                                                                If mes = december And dia >= 1 < 21 Then
                                                                                                    WriteLine(horosagitario & " mucha suerte")
                                                                                                    ReadLine()
                                                                                                Else
                                                                                                    If mes = december And dia >= 21 < 32 Then
                                                                                                        WriteLine(horocapricornio & " mucha suerte")
                                                                                                        ReadLine()
                                                                                                    Else
                                                                                                        WriteLine("Los datos ingresados no son correctos, deja de bromear conmigo que no tengo todo el dia ¿vale?")
                                                                                                        ReadLine()
                                                                                                    End If
                                                                                                End If
                                                                                            End If
                                                                                        End If
                                                                                    End If
                                                                                End If
                                                                            End If
                                                                        End If
                                                                    End If
                                                                End If
                                                            End If
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If

    End Sub

End Module


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 17 Mayo 2009, 23:44 pm
Al tratar de compilarlo te larga error?... Antes de ponerme a leer todos esos if's anidados te agradeceria que pongas el error al compilar.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: NetStorm en 17 Mayo 2009, 23:52 pm
No ningun error ... solo que no funciona ... le pongo por ejemplo agosto 30 y me dice que soy LEO ... !!!! diablos... que pasa?  :o


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 18 Mayo 2009, 01:08 am
Código
  1. Dim dia As String
  2. Dim mes As String
  3. Dim reponse As Boolean
  4. Private Sub Form_Load()
  5.    dia = InputBox("Ingrese dia", "Signos")
  6.    If dia = "" Then
  7.        End
  8.    End If
  9.    While (dia < 1) Or (dia > 31) Or (dia = "")
  10.        MsgBox "Error, los meses solo contienen dias entre 1 y 31", vbOKOnly
  11.        dia = InputBox("Ingrese dia", "Signos")
  12.    Wend
  13.    dia = Val(dia)
  14.    mes = InputBox("Ingrese mes", "Signos")
  15.    Select Case mes
  16.        Case "enero"
  17.        If dia < 21 Then
  18.            MsgBox "CAPRICORNIO", vbOKOnly
  19.        Else: MsgBox "ACUARIO", vbOKOnly
  20.        End If
  21.        Case "febrero"
  22.        If dia < 20 Then
  23.            MsgBox "ACUARIO", vbOKOnly
  24.        Else: MsgBox "PISCIS", vbOKOnly
  25.        End If
  26.        Case "marzo"
  27.        If dia < 21 Then
  28.            MsgBox "PISCIS", vbOKOnly
  29.        Else:  MsgBox "ARIES", vbOKOnly
  30.        End If
  31.        Case "abril"
  32.        If dia < 21 Then
  33.             MsgBox "ARIES", vbOKOnly
  34.        Else: MsgBox "TAURO", vbOKOnly
  35.        End If
  36.        Case "mayo"
  37.        If dia < 21 Then
  38.            MsgBox "TAURO", vbOKOnly
  39.        Else: MsgBox "GEMINIS", vbOKOnly
  40.        End If
  41.        Case "junio"
  42.        If dia < 22 Then
  43.            MsgBox "GEMINIS", vbOKOnly
  44.        Else: MsgBox "CANCER", vbOKOnly
  45.        End If
  46.        Case "julio"
  47.        If dia < 23 Then
  48.           MsgBox "CANCER", vbOKOnly
  49.        Else: MsgBox "LEO", vbOKOnly
  50.        End If
  51.        Case "agosto"
  52.        If dia < 23 Then
  53.            MsgBox "LEO", vbOKOnly
  54.        Else: MsgBox "VIRGO", vbOKOnly
  55.        End If
  56.        Case "setiembre"
  57.        If dia < 23 Then
  58.            MsgBox "VIRGO", vbOKOnly
  59.        Else: MsgBox "LIBRA", vbOKOnly
  60.        End If
  61.        Case "octubre"
  62.        If dia < 23 Then
  63.           MsgBox "LIBRA", vbOKOnly
  64.        Else: MsgBox "ESCORPIO", vbOKOnly
  65.        End If
  66.        Case "noviembre"
  67.        If dia < 22 Then
  68.            MsgBox "ESCORPIO", vbOKOnly
  69.        Else: MsgBox "SAGITARIO", vbOKOnly
  70.        End If
  71.        Case "diciembre"
  72.        If dia < 22 Then
  73.            MsgBox "SAGITARIO", vbOKOnly
  74.        Else: MsgBox "CAPRICORNIO", vbOKOnly
  75.        End If
  76.        Case Else
  77.        MsgBox "Error", vbOKOnly
  78. End Select
  79. End Sub
  80.  


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 18 Mayo 2009, 01:49 am
Ahora arreglado el tema de la entrada con mayuscula o minuscula... Usando Ucase() Solo falta depurar un poco más los signos, pero creo que ya esta bien.

Código
  1. Dim dia As String
  2. Dim mes As String
  3. Dim reponse As Boolean
  4. Private Sub Form_Load()
  5.    dia = InputBox("Ingrese dia", "Signos")
  6.    If dia = "" Then
  7.        End
  8.    End If
  9.    While (dia < 1) Or (dia > 31) Or (dia = "")
  10.        MsgBox "Error, los meses solo contienen dias entre 1 y 31", vbOKOnly
  11.        dia = InputBox("Ingrese dia", "Signos")
  12.    Wend
  13.    dia = Val(dia)
  14.    mes = InputBox("Ingrese mes", "Signos")
  15.    mes = UCase(mes)
  16.    Select Case mes
  17.        Case "ENERO"
  18.        If dia < 21 Then
  19.            MsgBox "CAPRICORNIO", vbOKOnly
  20.        Else: MsgBox "ACUARIO", vbOKOnly
  21.        End If
  22.        Case "FEBRERO"
  23.        If dia < 20 Then
  24.            MsgBox "ACUARIO", vbOKOnly
  25.        Else: MsgBox "PISCIS", vbOKOnly
  26.        End If
  27.        Case "MARZO"
  28.        If dia < 21 Then
  29.            MsgBox "PISCIS", vbOKOnly
  30.        Else:  MsgBox "ARIES", vbOKOnly
  31.        End If
  32.        Case "ABRIL"
  33.        If dia < 21 Then
  34.             MsgBox "ARIES", vbOKOnly
  35.        Else: MsgBox "TAURO", vbOKOnly
  36.        End If
  37.        Case "MAYO"
  38.        If dia < 21 Then
  39.            MsgBox "TAURO", vbOKOnly
  40.        Else: MsgBox "GEMINIS", vbOKOnly
  41.        End If
  42.        Case "JUNIO"
  43.        If dia < 21 Then
  44.            MsgBox "GEMINIS", vbOKOnly
  45.        Else: MsgBox "CANCER", vbOKOnly
  46.        End If
  47.        Case "JULIO"
  48.        If dia < 24 Then
  49.           MsgBox "CANCER", vbOKOnly
  50.        Else: MsgBox "LEO", vbOKOnly
  51.        End If
  52.        Case "AGOSTO"
  53.        If dia < 24 Then
  54.            MsgBox "LEO", vbOKOnly
  55.        Else: MsgBox "VIRGO", vbOKOnly
  56.        End If
  57.        Case "SETIEMBRE"
  58.        If dia < 24 Then
  59.            MsgBox "VIRGO", vbOKOnly
  60.        Else: MsgBox "LIBRA", vbOKOnly
  61.        End If
  62.        Case "OCTUBRE"
  63.        If dia < 24 Then
  64.           MsgBox "LIBRA", vbOKOnly
  65.        Else: MsgBox "ESCORPIO", vbOKOnly
  66.        End If
  67.        Case "NOVIEMBRE"
  68.        If dia < 22 Then
  69.            MsgBox "ESCORPIO", vbOKOnly
  70.        Else: MsgBox "SAGITARIO", vbOKOnly
  71.        End If
  72.        Case "DICIEMBRE"
  73.        If dia < 22 Then
  74.            MsgBox "SAGITARIO", vbOKOnly
  75.        Else: MsgBox "CAPRICORNIO", vbOKOnly
  76.        End If
  77.        Case Else
  78.        MsgBox "Error", vbOKOnly
  79. End Select
  80. End
  81. End Sub


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Jorgitoh en 18 Mayo 2009, 13:26 pm
Tene en cuenta que estas usando Windows Forms y el user solo esta manejando la Consola. De todos modos la sintaxis esta bien, solo habria que cambiar los Input Box por ReadLine y los Message por WriteLine.

Saludos.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 18 Mayo 2009, 16:00 pm
Si  :xD anoche estuve hablando con el y aclarando un par de dudas que tenia. El problema creo que se ha solucionado.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: NetStorm en 18 Mayo 2009, 17:54 pm
Gracias ha sido un trabajo exitoso, lo habeís hecho excelente agradecer profundamente a m@deb su ánimo desinteresado por su ayuda de forma "integra" y no mediocre, paso cerca de 3 horas explicándome muchas cosas que ahora tengo claras aunque en clases ni las he tocado (por ejem. los forms), y nada agradecer a todos los integrantes del foro que también aportaron lo suyo ...

Finalmente quiero solicitarle al mod del foro que de por cerrado el tema, ya que se ha solucionado el problema.

Gracias, sinceramente sos grandes como dice m@deb... vale Che'

Salu2 desde Arequipa - Perú.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: Myth.ck en 18 Mayo 2009, 18:11 pm
Pues de nada.
Cuando uno ayuda, tambien aprende muchas cosas, ya que no soy un Gurú de la programación.
Sin mas que decir.

Salu2!


Título: SOLUCIÓN !!!
Publicado por: NetStorm en 3 Junio 2009, 03:44 am
Bien para los interesados aquí está el código, como todavía veo que la prgunta está abierta, entonces posteo el código, OJO que esto es en modo consola, M@deb lo realizó en form, pero yo lo adapté a consola. En fin...

Código:
Imports system.console

Module module1
    Sub main()

        Dim dia As Integer
        Dim mes As String
        Dim feberror As Integer = 29

        Const horoaries As String = "hoy tendrás un gran día"
        Const horotauro As String = "hoy tendrás un gran día"
        Const horogeminis As String = "hoy tendrás un gran día"
        Const horocancer As String = "hoy tendrás un gran día"
        Const horoleo As String = "hoy tendrás un gran día"
        Const horovirgo As String = "hoy tendrás un gran día"
        Const horolibra As String = "hoy tendrás un gran día"
        Const horoescorpio As String = "hoy tendrás un gran día"
        Const horosagitario As String = "hoy tendrás un gran día"
        Const horocapricornio As String = "hoy tendrás un gran día"
        Const horoacuario As String = "hoy tendrás un gran día"
        Const horopiscis As String = "hoy tendrás un gran día"

        Writeline("Por favor, ingrese el dia de nacimiento")
        Dia = readline()
        If dia = (dia < 1) Or (dia > 31) Then
            WriteLine("Error, los meses solo contienen dias entre 1 y 31")
            ReadLine()
        Else
            WriteLine("Ahora ingrese el mes de nacimiento")
            mes = ReadLine()
            If mes = ("febrero") And (dia > 29) Then
                WriteLine("Oh, Oh!!!, febrero no tiene " & dia & " días, se le asignará 29 como valor")
                ReadLine()
                dia = 29
            Else
            End If
            mes = UCase(mes)
            Select Case mes
                Case "ENERO"
                    If dia < 21 Then
                        WriteLine("CAPRICORNIO " & horocapricornio)
                        ReadLine()
                    Else : WriteLine("ACUARIO " & horoacuario)
                        ReadLine()
                    End If
                Case "FEBRERO"
                    If dia < 20 Then
                        WriteLine("ACUARIO " & horoacuario)
                        ReadLine()
                    Else : WriteLine("PISCIS " & horopiscis)
                        ReadLine()
                    End If
                Case "MARZO"
                    If dia < 21 Then
                        WriteLine("PISCIS " & horopiscis)
                        ReadLine()
                    Else : WriteLine("ARIES " & horoaries)
                        ReadLine()
                    End If
                Case "ABRIL"
                    If dia < 21 Then
                        WriteLine("ARIES " & horoaries)
                        ReadLine()
                    Else : WriteLine("TAURO " & horotauro)
                        ReadLine()
                    End If
                Case "MAYO"
                    If dia < 21 Then
                        WriteLine("TAURO " & horotauro)
                        ReadLine()
                    Else : WriteLine("GEMINIS " & horogeminis)
                        ReadLine()
                    End If
                Case "JUNIO"
                    If dia < 21 Then
                        WriteLine("GEMINIS " & horogeminis)
                        ReadLine()
                    Else : WriteLine("CANCER " & horocancer)
                        ReadLine()
                    End If
                Case "JULIO"
                    If dia < 24 Then
                        WriteLine("CANCER " & horocancer)
                        ReadLine()
                    Else : WriteLine("LEO " & horoleo)
                        ReadLine()
                    End If
                Case "AGOSTO"
                    If dia < 24 Then
                        WriteLine("LEO " & horoleo)
                        ReadLine()
                    Else : WriteLine("VIRGO " & horovirgo)
                        ReadLine()
                    End If
                Case "SETIEMBRE"
                    If dia < 24 Then
                        WriteLine("VIRGO " & horovirgo)
                        ReadLine()
                    Else : WriteLine("LIBRA " & horolibra)
                        ReadLine()
                    End If
                Case "OCTUBRE"
                    If dia < 24 Then
                        WriteLine("LIBRA " & horolibra)
                        ReadLine()
                    Else : WriteLine("ESCORPIO " & horoescorpio)
                        ReadLine()
                    End If
                Case "NOVIEMBRE"
                    If dia < 22 Then
                        WriteLine("ESCORPIO " & horoescorpio)
                        ReadLine()
                    Else : WriteLine("SAGITARIO " & horosagitario)
                        ReadLine()
                    End If
                Case "DICIEMBRE"
                    If dia < 22 Then
                        WriteLine("SAGITARIO " & horosagitario)
                        ReadLine()
                    Else : WriteLine("CAPRICORNIO " & horocapricornio)
                        ReadLine()
                    End If
                Case Else
                    Write("Oh, oh!!!, ... Ha ocurrido un error los datos ingresados no son válidos")
                    ReadLine()
            End Select
            End If
    End Sub
End Module


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: h0oke en 3 Junio 2009, 03:52 am
Código
  1.        Const horoaries As String = "hoy tendrás un gran día"
  2.        Const horotauro As String = "hoy tendrás un gran día"
  3.        Const horogeminis As String = "hoy tendrás un gran día"
  4.        Const horocancer As String = "hoy tendrás un gran día"
  5.        Const horoleo As String = "hoy tendrás un gran día"
  6.        Const horovirgo As String = "hoy tendrás un gran día"
  7.        Const horolibra As String = "hoy tendrás un gran día"
  8.        Const horoescorpio As String = "hoy tendrás un gran día"
  9.        Const horosagitario As String = "hoy tendrás un gran día"
  10.        Const horocapricornio As String = "hoy tendrás un gran día"
  11.        Const horoacuario As String = "hoy tendrás un gran día"
  12.        Const horopiscis As String = "hoy tendrás un gran día"

Una pregunta.. ¿Por qué declaras tantas veces lo mismo? No daría igual que uses:

Código
  1. Const Horoscopo As String= "Hoy tendrás un gran dia"


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: NetStorm en 6 Junio 2009, 18:26 pm
Cierto ... tu lógica es aplastante, pero sabes, yo consideré la oportunidad de decirle a cada signo una cosa distinta, y como ves no soy bueno con eso de los horóscopos, imagina que en tu variable coloques "Hoy te amputaran la pierna", ¿a todos los signos les dirás lo mismo?, solo era cuestión de modificar el texto a distintas predicciones para cada signo, eso fue lo que yo consideré, pero como digo ... no soy bueno en eso, será que jamás creo en la suerte.  ;D


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: h0oke en 6 Junio 2009, 18:38 pm
 :D Entonces... no dije nada...  ::) Es verdad lo que dices, pero yo pensé que habias presentado de esa manera el programa.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: seba123neo en 7 Junio 2009, 00:44 am
Hola, mira este codigo yo lo habia realizado cuando tuve que hacer algo parecido...es una funcion que se encarga de calcular el signo...y te ahorras todos esos SELECT CASE que no me gustan cuando son muchos...

Código
  1. Imports system.console
  2.  
  3. Module module1
  4.    Private Enum MESES
  5.        ENERO = 1
  6.        FEBRERO = 2
  7.        MARZO = 3
  8.        ABRIL = 4
  9.        MAYO = 5
  10.        JUNIO = 6
  11.        JULIO = 7
  12.        AGOSTO = 8
  13.        SEPTIEMBRE = 9
  14.        OCTUBRE = 10
  15.        NOVIEMBRE = 11
  16.        DICIEMBRE = 12
  17.    End Enum
  18.  
  19.    Const horoaries As String = "hoy tendrás un gran día"
  20.    Const horotauro As String = "hoy tendrás un gran día"
  21.    Const horogeminis As String = "hoy tendrás un gran día"
  22.    Const horocancer As String = "hoy tendrás un gran día"
  23.    Const horoleo As String = "hoy tendrás un gran día"
  24.    Const horovirgo As String = "hoy tendrás un gran día"
  25.    Const horolibra As String = "hoy tendrás un gran día"
  26.    Const horoescorpio As String = "hoy tendrás un gran día"
  27.    Const horosagitario As String = "hoy tendrás un gran día"
  28.    Const horocapricornio As String = "hoy tendrás un gran día"
  29.    Const horoacuario As String = "hoy tendrás un gran día"
  30.    Const horopiscis As String = "hoy tendrás un gran día"
  31.  
  32.    Sub main()
  33.  
  34.        Dim dia As Integer
  35.        Dim mes As String
  36.        Dim feberror As Integer = 29
  37.        Dim vMes As MESES
  38.  
  39.        WriteLine("Por favor, ingrese el dia de nacimiento")
  40.        dia = ReadLine()
  41.  
  42.        If dia = (dia < 1) Or (dia > 31) Then
  43.            WriteLine("Error, los meses solo contienen dias entre 1 y 31")
  44.            ReadLine()
  45.        Else
  46.            WriteLine("Ahora ingrese el mes de nacimiento")
  47.            mes = ReadLine()
  48.  
  49.            If mes = ("febrero") And (dia > 29) Then
  50.                WriteLine("Oh, Oh!!!, febrero no tiene " & dia & " días, se le asignará 29 como valor")
  51.                ReadLine()
  52.                dia = 29
  53.            Else
  54.            End If
  55.  
  56.            mes = UCase(mes)
  57.  
  58.            Dim a() As String = System.Enum.GetNames(vMes.GetType)
  59.            Dim vIndiceMes As Integer
  60.            For i As Integer = 0 To a.Length - 1
  61.                If mes = a.GetValue(i) Then
  62.                    vIndiceMes = i + 1
  63.                    WriteLine(Zodiaco(vIndiceMes & dia))
  64.                    ReadLine()
  65.                    Exit Sub
  66.                End If
  67.            Next
  68.  
  69.            WriteLine("Oh, oh!!!, ... Ha ocurrido un error los datos ingresados no son válidos")
  70.            ReadLine()
  71.        End If
  72.    End Sub
  73.  
  74.    Private Function Zodiaco(ByVal Fecha As Integer) As String
  75.        If Fecha <= 219 And Fecha >= 121 Then
  76.            Zodiaco = "ACURARIO " & horoacuario
  77.        ElseIf Fecha <= 320 And Fecha >= 220 Then
  78.            Zodiaco = "PISCIS " & horopiscis
  79.        ElseIf Fecha <= 420 And Fecha >= 321 Then
  80.            Zodiaco = "ARIES " & horoaries
  81.        ElseIf Fecha <= 521 And Fecha >= 421 Then
  82.            Zodiaco = "TAURO " & horotauro
  83.        ElseIf Fecha <= 621 And Fecha >= 522 Then
  84.            Zodiaco = "GEMINIS " & horogeminis
  85.        ElseIf Fecha <= 722 And Fecha >= 622 Then
  86.            Zodiaco = "CANCER " & horocancer
  87.        ElseIf Fecha <= 822 And Fecha >= 723 Then
  88.            Zodiaco = "LEO " & horoleo
  89.        ElseIf Fecha <= 923 And Fecha >= 823 Then
  90.            Zodiaco = "VIRGO " & horovirgo
  91.        ElseIf Fecha <= 1023 And Fecha >= 924 Then
  92.            Zodiaco = "LIBRA " & horolibra
  93.        ElseIf Fecha <= 1122 And Fecha >= 1024 Then
  94.            Zodiaco = "ESCORPIO " & horoescorpio
  95.        ElseIf Fecha <= 1221 And Fecha >= 1123 Then
  96.            Zodiaco = "SAGITARIO " & horosagitario
  97.        Else
  98.            Zodiaco = "CAPRICORNIO " & horocapricornio
  99.        End If
  100.    End Function
  101. End Module

saludos.


Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: cobolitros en 4 Mayo 2011, 14:27 pm

Disculpen pero como se podria obtener el Signo zodiacal pero con vectores



Título: Re: Ayudas o sugerencias - programa signo zodiaco
Publicado por: cocori002 en 16 Noviembre 2013, 00:23 am
Hola, ¿alguien sabe como hacer un script de linux que te pida día y mes y te diga el signo del zodiaco? yo lo he intentado con todo y no me sale de ninguna manera...

Saludos.