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"
Code java:
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 + ".");
}
}
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
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. =(
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?
Quote:
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???
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?
Re: need to figure how this thing will work