for example:
Enter the birth date (mm/dd/yyyy):7 / 27 / 1981
after entering the date is should display "Welcome to the Numerology report for 7/27/1981: and tell me my fortune BUT INSTEAD i wont display anything.
also
lest say i enter 0 / 10 / 2000
then it displays:Bad month:0 which is good but if i enter a good date after that for example 2 / 28 / 2007 then the program just keeps asking me to enter a birth date again and again.
and i have no idea what is wrong
import java.util.Scanner;
public class plira_Numerology
{
public static void main (String args[])
{
int month;
int day;
int year;
int date;
int numerology;
char symbol;
int t;
Scanner input =new Scanner(System.in);
System.out.print("Enter the birth date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
if(month<1||month>12||year<1880||year>2280||symbol!='/'||month==2)
t=44;
else{t=45;}
do{
while(month<1||month>12){
System.out.printf("Bad month:%d\n",month);
System.out.print("Enter birth date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}
while (symbol!='/'){
System.out.print("Use forward slashes between mm/dd/yyyy!\n");
System.out.print("Enter birth date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}
while(year<1880||year>2280){
System.out.printf("Bad year for %d\n",year);
System.out.print("Enter birth date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}
while(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
if(day<1||day>31){
System.out.printf("Bad day for %d/%d : %d\n",month,year,day);
System.out.print("Enter birth date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}}
while(month==4||month==6||month==9|month==11){
if(day<1||day>30){
System.out.printf("Bad day for %d/%d : %d\n",month,year,day);
System.out.print("Enter birht date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}}
while(month==2){
if(year%4==0||year%400==0||year==2000){
if(day<1||day>29)
System.out.printf("bad day for %d/%d : %d\n",month,year,day);
System.out.print("Enter birht date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}
if (year%4!=0||year%100==0||year%400!=0||year!=2000){
if(day<1||day>28)
System.out.printf("bad day for %d/%d/ : %d\n",month,year,day);
System.out.print("Enter birht date (mm/dd/yyyy):");
month=input.nextInt();
symbol=input.next().charAt(0);
day=input.nextInt();
symbol=input.next().charAt(0);
year=input.nextInt();
}}
}while(t==44);
if(t==45){
System.out.printf("Welcome to the numerology report for %d/%d/%d :\n",month,day,year);
date=month+day+year;
do{
date=((date%10)+(date/10));
}while(date>=10);
numerology=date;
switch(numerology)
{
case 1:
System.out.print(":1: Your luck is about to change so get ready! ");
break;
case 2:
System.out.print(":2: keep trying you are making it. ");
break;
case 3:
System.out.print(":3: its time to relax! ");
break;
case 4:
System.out.print(":4:Money prolems are about to get solved. ");
break;
case 5:
System.out.print(":5: if you stay optimistic your dream will come true.");
break;
case 6:
System.out.print(":6: although things may seem bad don't worry.");
break;
case 7:
System.out.print(":7: you are about to find the love of your life.");
break;
case 8:
System.out.print(":8: too much fun is not very healthy.");
break;
case 9:
System.out.print(":9: something unexpected will happen today.");
break;
}}
}
}

New Topic/Question
Reply




MultiQuote






|