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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yanalvine
    New Member
    • Oct 2013
    • 8

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

    Code:
    import java.util.*;
    
    public class zodiac2 {
    public static void main(String[] args) {
    String sign="";
    
    
    int month, day,year;
    
    Scanner c = new Scanner (System.in);
    System.out.println("Enter day(1-31): ");
    day = c.nextInt();
    System.out.println("Enter month(1-12): ");
    month = c.nextInt();
    System.out.println("Enter year: ");
    year = c.nextInt();
    
    if((month == 1) && (day <= 20) || (month == 12) && (day >= 22)) {
    sign = "Capricorn";
    } else if((month == 1) || (month == 2) && (day <= 19)) {
    sign = "Aquarius";
    } else if((month == 2) || (month == 3) && (day <= 20)) {
    sign = "Pisces";
    } else if((month == 3) || (month == 4) && (day <= 19)) {
    sign = "Aries";
    } else if((month == 4) || (month == 5) && (day <= 21)) {
    sign = "Taurus";
    } else if((month == 5) || (month == 6) && (day <= 21)) {
    sign = "Gemini";
    } else if((month == 6) || (month == 7) && (day <= 23)) {
    sign = "Cancer";
    } else if((month == 7) || (month == 8) && (day <= 23)) {
    sign = "Leo";
    } else if((month == 8) || (month == 9) && (day <= 23)) {
    sign = "Virgo";
    } else if((month == 9) || (month == 10) && (day <= 23)) {
    sign = "Libra";
    } else if((month == 10) || (month == 11) && (day <= 22)) {
    sign = "Scorpio";
    } else if(month == 12) {
    sign = "Sagittarius";
    }
    
    }
    
    
    System.out.println("Your Zodiac sign is "+sign+".");
    
    
    }
    Last edited by Rabbit; Oct 21 '13, 06:40 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • yanalvine
    New Member
    • Oct 2013
    • 8

    #2
    hello i cant find where to correct it, can someone help

    Comment

    • janculoo
      New Member
      • Oct 2013
      • 1

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

      Code:
      	} else if(month == 12) {
      			sign = "Sagittarius";
      		}
      				System.out.println("Your Zodiac sign is " + sign + ".");
      
      	}

      Comment

      Working...