Created
February 15, 2014 17:59
-
-
Save alvareztech/9022820 to your computer and use it in GitHub Desktop.
Java: Obtener signo zodiacal dados dia y mes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String signo(int dia, int mes) { | |
| String signo = ""; | |
| switch (mes) { | |
| case 1: | |
| if (dia > 21) { | |
| signo = "ACUARIO"; | |
| } else { | |
| signo = "CAPRICORNIO"; | |
| } | |
| break; | |
| case 2: | |
| if (dia > 19) { | |
| signo = "PISCIS"; | |
| } else { | |
| signo = "ACUARIO"; | |
| } | |
| break; | |
| case 3: | |
| if (dia > 20) { | |
| signo = "ARIES"; | |
| } else { | |
| signo = "PISCIS"; | |
| } | |
| break; | |
| case 4: | |
| if (dia > 20) { | |
| signo = "TAURO"; | |
| } else { | |
| signo = "ARIES"; | |
| } | |
| break; | |
| case 5: | |
| if (dia > 21) { | |
| signo = "GEMINIS"; | |
| } else { | |
| signo = "TAURO"; | |
| } | |
| break; | |
| case 6: | |
| if (dia > 20) { | |
| signo = "CANCER"; | |
| } else { | |
| signo = "GEMINIS"; | |
| } | |
| break; | |
| case 7: | |
| if (dia > 22) { | |
| signo = "LEO"; | |
| } else { | |
| signo = "CANCER"; | |
| } | |
| break; | |
| case 8: | |
| if (dia > 21) { | |
| signo = "VIRGO"; | |
| } else { | |
| signo = "LEO"; | |
| } | |
| break; | |
| case 9: | |
| if (dia > 22) { | |
| signo = "LIBRA"; | |
| } else { | |
| signo = "VIRGO"; | |
| } | |
| break; | |
| case 10: | |
| if (dia > 22) { | |
| signo = "ESCORPION"; | |
| } else { | |
| signo = "LIBRA"; | |
| } | |
| break; | |
| case 11: | |
| if (dia > 21) { | |
| signo = "SAGITARIO"; | |
| } else { | |
| signo = "ESCORPION"; | |
| } | |
| break; | |
| case 12: | |
| if (dia > 21) { | |
| signo = "CAPRICORNIO"; | |
| } else { | |
| signo = "SAGITARIO"; | |
| } | |
| break; | |
| } | |
| return signo; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracias por tu aporte, justo tuve que hacer un trabajo sobre esto y me sirvió mucho tu código. Te muestro lo que hice
package signozodiaco;
import java.util.Scanner;
public class SignoZodiaco {
}
----------------------------------------------------------------------------------------------------------------------------------------package signozodiaco;
public class Signo {
}