类赋值命理报告Java代码

类赋值命理报告Java代码,java,debugging,compiler-errors,Java,Debugging,Compiler Errors,编写一个程序,将一个人的出生日期的数字相加,以获得一个数字,从而生成一份命理报告 下面是我的代码,它基本上是完整的,但我不知道它是否正确,因为当我试图编译它时,我得到一条错误消息,我需要一个“;”在第一段时间之后,但是当我添加;这只会让我犯更多的错误。感谢您的帮助,谢谢 import java.util.Scanner; public class rneely_Numerology { public static void main (String args []) {

编写一个程序,将一个人的出生日期的数字相加,以获得一个数字,从而生成一份命理报告

下面是我的代码,它基本上是完整的,但我不知道它是否正确,因为当我试图编译它时,我得到一条错误消息,我需要一个“;”在第一段时间之后,但是当我添加;这只会让我犯更多的错误。感谢您的帮助,谢谢

import java.util.Scanner;

public class rneely_Numerology {

    public static void main (String args [])
    {
        int date = 0;
        int sum;
        int day = 0;
        int month = 0;
        int year = 0;
        int numerology = 0;
        int tempnumerology = 0;
        char A;
        char B;
        int leapyear = 0;

        leapyear = year % 4;

        Scanner input = new Scanner (System.in);

        do {
            System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
            month = input.nextInt();
            A = input.next().charAt(0);
            day = input.nextInt();
            B = input.next().charAt(0);
            year = input.nextInt();
        }
        while (month < 1 || month > 12)
            {
                System.out.printf ( "Bad month: %d\n", month);
                System.out.println();
                System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
                month = input.nextInt();
                A = input.next().charAt(0);
                day = input.nextInt();
                B = 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: %d\n", day);
                    System.out.println();
                }
                System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
                month = input.nextInt();
                A = input.next().charAt(0);
                day = input.nextInt();
                                                                                   B = 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: %d\n", day);
                    System.out.println();
                }

                System.out.print ( "Enter the birth day (mm/dd/yyyy): ");
                month = input.nextInt();
                A = input.next().charAt(0);
                day = input.nextInt();
                B = input.next().charAt(0);
                year = input.nextInt();
            }
            while (month == 2);
            {
                if (year % 400 = 0) {
                    if (year % 100 = 0) {}}
                else if (year % 4 = 0)
                {
                    if (day < 1 || day > 29)
                    {
                        System.out.printf ( "Bad day for %d%d: %d\n", month, year, day);
                        System.out.println();
                    }
                }
                else
                {
                    if (day < 1 || day > 28)
                    {
                        System.out.printf ( "Bad day for %d%d: %d\n", month, year, day);
                        System.out.println();
                    }
                }

                System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
                month = input.nextInt();
                A = input.next().charAt(0);
                day = input.nextInt();
                B = input.next().charAt(0);
                year = input.nextInt();
            }
            while (year < 1880 || year > 2280);
            {
                System.out.printf ( "Bad year: %d\n", year);
                System.out.println();
                            System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
                month = input.nextInt();
                A = input.next().charAt(0);
                day = input.nextInt();
                B = input.next().charAt(0);
                year = input.nextInt();
            }
            while (A != '/' || B != '/');

            System.out.print ( "Use forward slashes between month, day, and year!\n" );
            System.out.println();
            System.out.print ( "Enter the birth date (mm/dd/yyyy): ");
            month = input.nextInt();
            A = input.next().charAt(0);
            day = input.next.Int();
            B = input.next().charAt(0);
            year = input.nextInt();



            date = month + day + year;
            for ( int numerology = date; numerology <= 9; numerology %= 10 ) {
                date = numerology;
            }

            System.out.printf ( "Welcome to the numerology report for %d/%d/%d\n", month, day, year);

            switch (numerology)
            {
                case 1:
                    System.out.println ( "-1- Hard work pays off in the future, laziness pays off now. ");
                    break;
                case 2:
                    System.out.println ( "-2- You learn from your mistakes... you will learn a lot today. ");
                    break;
                case 3:
                    System.out.println ( "-3- Your high minded principles spell success. ");
                    break;
                case 4:
                    System.out.println ( "-4- A dream you have will come true. ");
                    break;
                case 5:
                    System.out.println ( "-5- The greatest risk is not taking one. ");
                    break;
                case 6:
                    System.out.println ( "-6- Your ability for accomplishment will follow with success. ");
                    break;
                case 7:
                    System.out.println ( "-7- You will travel to many exotic places in your lifetime. ");
                    break;
                case 8:
                     System.out.println ( "-8- Keep your eye out for someone special. ");
                    break;
                case 9:
                    System.out.println ( "-9- Now is the time to try something new. ");
                    break;
            }
        }

    }
import java.util.Scanner;
公共类数字命理学{
公共静态void main(字符串参数[])
{
int date=0;
整数和;
整日=0;
整月=0;
整年=0;
整数命理=0;
整数温度命理=0;
字符A;
字符B;
整年=0;
闰年=年份%4;
扫描仪输入=新扫描仪(System.in);
做{
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(月<1 | |月>12)
{
System.out.printf(“坏月:%d\n”,月);
System.out.println();
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(月=1 |月=3 |月=5 |月=7 |月=8 |月=10 |月=12);
{
如果(第1天|第31天)
{
System.out.printf(“糟糕的一天:%d\n”,天);
System.out.println();
}
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(月=4 |月=6 |月=9 |月=11);
{
如果(日<1 | |日>30)
{
System.out.printf(“糟糕的一天:%d\n”,天);
System.out.println();
}
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(月=2);
{
如果(年份%400=0){
如果(年份%100=0){}
否则如果(第%4年=0)
{
如果(天<1 | |天>29)
{
System.out.printf(“对于%d%d:%d\n”,月、年、日,糟糕的一天”);
System.out.println();
}
}
其他的
{
如果(天<1 | |天>28)
{
System.out.printf(“对于%d%d:%d\n”,月、年、日,糟糕的一天”);
System.out.println();
}
}
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(年份<1880 | |年份>2280);
{
System.out.printf(“坏年份:%d\n”,年份);
System.out.println();
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.nextInt();
B=输入.next().charAt(0);
年份=input.nextInt();
}
而(A!='/'| B!='/');
System.out.print(“在月、日和年之间使用前斜杠!\n”);
System.out.println();
System.out.print(“输入出生日期(mm/dd/yyyy):”;
month=input.nextInt();
A=输入.next().charAt(0);
day=input.next.Int();
B=输入.next().charAt(0);
年份=input.nextInt();
日期=月+日+年;

对于(int numeriology=date;numeriology而言,后面的语法不正确。请在下面找到一个已更正的程序

import java.util.Scanner;

public class Numerology {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        do {
            System.out.println("Enter the birth date (mm/dd/yyyy): ");
            String inp = input.nextLine();
            Integer month = null;
            Integer day = null;
            Integer year = null;
            try {
                String[] inpArr = inp.split("/");
                month = Integer.parseInt(inpArr[0]);
                day = Integer.parseInt(inpArr[1]);
                year = Integer.parseInt(inpArr[2]);
            } catch (Exception e) {
                System.out.println("Use forward slashes between month, day, and year!");
                continue;
            }
            String[] inpArr = inp.split("/");

            if (month < 1 || month > 12) {
                System.out.println("Bad Month : " + month);
                continue;
            }

            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                if (day < 1 || day > 31) {
                    System.out.println("Bad day: " + day);
                    continue;
                }
            } else if (month == 2) {
                if (year % 4 == 0) {
                    if (day < 1 || day > 29) {
                        System.out.println("Bad day: " + day);
                        continue;
                    }
                } else {
                    if (day < 1 || day > 28) {
                        System.out.println("Bad day: " + day);
                        continue;
                    }
                }
            } else {
                if (day < 1 || day > 30) {
                    System.out.println("Bad day: " + day);
                    continue;
                }
            }

            if (year < 1880 || year > 2280) {
                System.out.println("Bad year: " + year);
                continue;
            }

            String date = (month + day + year) + "";

            int sum = 11;
            while (sum > 10) {
                sum = 0;
                String[] dateArr = date.split("");
                for (int i = 0; i < dateArr.length; i++) {
                    sum += Integer.parseInt(dateArr[i]);
                }
                date = sum + "";
            }

            switch (sum) {
            case 1:
                System.out.println("-1- Hard work pays off in the future, laziness pays off now. ");
                break;
            case 2:
                System.out.println("-2- You learn from your mistakes... you will learn a lot today. ");
                break;
            case 3:
                System.out.println("-3- Your high minded principles spell success. ");
                break;
            case 4:
                System.out.println("-4- A dream you have will come true. ");
                break;
            case 5:
                System.out.println("-5- The greatest risk is not taking one. ");
                break;
            case 6:
                System.out.println("-6- Your ability for accomplishment will follow with success. ");
                break;
            case 7:
                System.out.println("-7- You will travel to many exotic places in your lifetime. ");
                break;
            case 8:
                System.out.println("-8- Keep your eye out for someone special. ");
                break;
            case 9:
                System.out.println("-9- Now is the time to try something new. ");
                break;
            }
            break;
        } while (true);
        input.close();
    }
}
import java.util.Scanner;
公共类命理学{
公共静态void main(字符串[]args){
扫描仪输入=新扫描仪(System.in);
做{
System.out.println(“输入出生日期(mm/dd/yyyy):”;
字符串inp=input.nextLine();
整月=空;
整数天=空;
整年=空;
试一试{
字符串[]inpArr=inp.split(“/”);
month=Integer.parseInt(inpArr[0]);
day=Integer.parseInt(inpArr[1]);
year=Integer.parseInt(inpArr[2]);
}捕获(例外e){
System.out.println(“在月、日和年之间使用前斜杠!”);
继续;
}
字符串[]inpArr=inp.split(“/”);
如果(月<1 | |月>12){
System.out.println(“坏月:+月”);
继续;
}
如果(月=1 |月=3 |月=5 |月=7 |月=8 |月=10 |月=12){