Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: need to figure how this thing will work

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default need to figure how this thing will work

    my advisor told me that " INPUT FROM A FILE,IT SHOULD HAVE MORE THAN ONE BIRTHDAY AT OUTPUT ALSO TO A FILE"

    import java.util.*;
     
    public class ZodiacSign {
    	public static void main(String[] args) {
    		String sign = "";
    		String element = "";
    		String chineseSign = "";
    		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";
    		}
    		if ((sign.equals("Aries")) || (sign.equals("Leo"))
    				|| (sign.equals("Sagittarius"))) {
    			element = "Fire";
    		} else if ((sign.equals("Taurus")) || (sign.equals("Virgo"))
    				|| (sign.equals("Capricorn"))) {
    			element = "Earth";
    		} else if ((sign.equals("Gemini")) || (sign.equals("Libra"))
    				|| (sign.equals("Aquarius"))) {
    			element = "Air";
    		} else if ((sign.equals("Cancer")) || (sign.equals("Scorpio"))
    				|| (sign.equals("Pisces"))) {
    			element = "Water";
    		}
     
    		int x = (1997 - year) % 12;
    		if ((x == 1) || (x == -11)) {
    			chineseSign = "Rat";
    		} else {
    			if (x == 0) {
    				chineseSign = "Ox";
    			} else {
    				if ((x == 11) || (x == -1)) {
    					chineseSign = "Tiger";
    				} else {
    					if ((x == 10) || (x == -2)) {
    						chineseSign = "Rabbit";
    					} else {
    						if ((x == 9) || (x == -3)) {
    							chineseSign = "Dragon";
    						} else {
    							if ((x == 8) || (x == -4)) {
    								chineseSign = "Snake";
    							} else {
    								if ((x == 7) || (x == -5)) {
    									chineseSign = "Horse";
    								} else {
    									if ((x == 6) || (x == -6)) {
    										chineseSign = "Sheep";
    									} else {
    										if ((x == 5) || (x == -7)) {
    											chineseSign = "Monkey";
    										} else {
    											if ((x == 4) || (x == -8)) {
    												chineseSign = "Chicken";
    											} else {
    												if ((x == 3) || (x == -9)) {
    													chineseSign = "Dog";
    												} else {
    													if ((x == 2) || (x == -10)) {
    														chineseSign = "Pig";
    													}
    												}
    											}
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
     
    		System.out.println("Your Zodiac sign is " + sign + ".");
    		System.out.println("Chinese Zodiac is: " + chineseSign + ".");
    		System.out.println("Element is " + element + ".");
    	}
    }


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: need to figure how this thing will work

    Welcome to the forums frosst.

    What is the problem here? You need to tell us what is happening when you compile the program. Where are you stuck?

    It looks like the program works well in the console. If you need to read/write to a file, I suggest you read:

    http://www.javaprogrammingforums.com...ner-class.html

    http://www.javaprogrammingforums.com...sing-java.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. The Following User Says Thank You to JavaPF For This Useful Post:

    frosst (May 25th, 2011)

  4. #3
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: need to figure how this thing will work

    hello sir good evening. im not quite sure about this actually my professor told me that, "INPUT FROM A FILE,IT SHOULD HAVE MORE THAN ONE BIRTHDAY AT OUTPUT ALSO TO A FILE" im pretty sure the program is working, but when she told me that, that's the time i was lost with it. now im totally lost with it. =(

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,077
    Thanks
    47
    Thanked 2,147 Times in 2,120 Posts

    Default Re: need to figure how this thing will work

    First you need to understand what the program is supposed to do.
    Can you explain in simple steps what you want your code to do?

    INPUT FROM A FILE,IT SHOULD HAVE MORE THAN ONE BIRTHDAY AT OUTPUT ALSO TO A FILE"
    This description doesn't make sense to me.
    INPUT FROM A FILE - read something from a file
    IT SHOULD HAVE MORE THAN ONE BIRTHDAY - there is more than one entry
    AT OUTPUT ALSO TO A FILE - No idea what this means???
    Last edited by Norm; May 25th, 2011 at 03:52 PM.

  6. The Following User Says Thank You to Norm For This Useful Post:

    frosst (May 25th, 2011)

  7. #5
    Member
    Join Date
    Jan 2011
    Posts
    78
    My Mood
    Confused
    Thanks
    23
    Thanked 1 Time in 1 Post

    Default Re: need to figure how this thing will work

    So it's suppose to read multiple birth dates from a file. And then output them with their zodiac in a different file?

  8. #6
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: need to figure how this thing will work

    yes sir @hallowed

Similar Threads

  1. [SOLVED] Method help, one thing then another - puzzle
    By Scotty in forum Java Theory & Questions
    Replies: 3
    Last Post: April 28th, 2011, 01:52 PM
  2. I'm new at this and can't figure it out
    By jaheh06 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 22nd, 2010, 08:44 AM
  3. Weird thing with JFrame
    By Brt93yoda in forum AWT / Java Swing
    Replies: 2
    Last Post: August 23rd, 2010, 05:00 PM
  4. Stupid thing can't find image icon right in front of it!!!
    By javapenguin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: July 9th, 2010, 01:02 AM
  5. Trying 3 different ways to do the same thing, each one is wrong
    By shemer77 in forum What's Wrong With My Code?
    Replies: 14
    Last Post: June 4th, 2010, 07:01 PM