By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,649 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,649 IT Pros & Developers. It's quick & easy.

in my code below i have a small error in the line(System.out.println("Your Zodiac si)

P: 8
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3. public class zodiac2 {
  4. public static void main(String[] args) {
  5. String sign="";
  6.  
  7.  
  8. int month, day,year;
  9.  
  10. Scanner c = new Scanner (System.in);
  11. System.out.println("Enter day(1-31): ");
  12. day = c.nextInt();
  13. System.out.println("Enter month(1-12): ");
  14. month = c.nextInt();
  15. System.out.println("Enter year: ");
  16. year = c.nextInt();
  17.  
  18. if((month == 1) && (day <= 20) || (month == 12) && (day >= 22)) {
  19. sign = "Capricorn";
  20. } else if((month == 1) || (month == 2) && (day <= 19)) {
  21. sign = "Aquarius";
  22. } else if((month == 2) || (month == 3) && (day <= 20)) {
  23. sign = "Pisces";
  24. } else if((month == 3) || (month == 4) && (day <= 19)) {
  25. sign = "Aries";
  26. } else if((month == 4) || (month == 5) && (day <= 21)) {
  27. sign = "Taurus";
  28. } else if((month == 5) || (month == 6) && (day <= 21)) {
  29. sign = "Gemini";
  30. } else if((month == 6) || (month == 7) && (day <= 23)) {
  31. sign = "Cancer";
  32. } else if((month == 7) || (month == 8) && (day <= 23)) {
  33. sign = "Leo";
  34. } else if((month == 8) || (month == 9) && (day <= 23)) {
  35. sign = "Virgo";
  36. } else if((month == 9) || (month == 10) && (day <= 23)) {
  37. sign = "Libra";
  38. } else if((month == 10) || (month == 11) && (day <= 22)) {
  39. sign = "Scorpio";
  40. } else if(month == 12) {
  41. sign = "Sagittarius";
  42. }
  43.  
  44. }
  45.  
  46.  
  47. System.out.println("Your Zodiac sign is "+sign+".");
  48.  
  49.  
  50. }
Oct 21 '13 #1

✓ answered by janculoo

Copy and paste your print line in the method body because right now it is outside of it. So it should look like this

Expand|Select|Wrap|Line Numbers
  1.     } else if(month == 12) {
  2.             sign = "Sagittarius";
  3.         }
  4.                 System.out.println("Your Zodiac sign is " + sign + ".");
  5.  
  6.     }

Share this Question
Share on Google+
2 Replies


P: 8
hello i cant find where to correct it, can someone help
Oct 21 '13 #2

P: 1
Copy and paste your print line in the method body because right now it is outside of it. So it should look like this

Expand|Select|Wrap|Line Numbers
  1.     } else if(month == 12) {
  2.             sign = "Sagittarius";
  3.         }
  4.                 System.out.println("Your Zodiac sign is " + sign + ".");
  5.  
  6.     }
Oct 21 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.