elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Ayudas o sugerencias - programa signo zodiaco
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 3 Ir Abajo Respuesta Imprimir
Autor Tema: Ayudas o sugerencias - programa signo zodiaco  (Leído 31,751 veces)
NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
Ayudas o sugerencias - programa signo zodiaco
« 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.


En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #1 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.  


En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
Shell Root
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.723


<3


Ver Perfil WWW
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #2 en: 16 Mayo 2009, 07:00 am »

Servira de Guia, porque eso no es VB... xD

Saludos!!!
En línea

Por eso no duermo, por si tras mi ventana hay un cuervo. Cuelgo de hilos sueltos sabiendo que hay veneno en el aire.
Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #3 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

En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
Jorgitoh

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #4 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.
En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #5 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
En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #6 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
En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #7 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.
En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #8 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
En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #9 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.  
« Última modificación: 18 Mayo 2009, 01:24 am por m@deb » En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
Páginas: [1] 2 3 Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines