在if语句之前运行的print语句

时间:2015-06-17 22:27:14

标签: java

我使用Java程序将英文日期转换为威尔士日期,但if语句似乎没有运行,因为日期不会改变。我做错了什么?

我是Java的新手,我学习了Python,现在正在自学Java。这个英语到威尔士语的日期转换器是我用Python设置的一项任务,现在我已经将它设置为Java。

代码:

import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        System.out.println("What is the Date?:");
        Scanner date = new Scanner (System.in);
        String Date = date.next();
        date.nextLine();
        System.out.println("What Day is it?:");
        Scanner day = new Scanner (System.in);
        String Day = day.next();
        day.nextLine();
        System.out.println("What Month is it?:");
        Scanner month = new Scanner (System.in);
        String Month = month.next();
        month.nextLine();
        if (Day == "Monday"){
            Day = "Dydd Llun";
        }
        if (Day == "Tuesday"){
            Day = "Dydd Mawrth";
        }
        if (Day == "Wednesday"){
            Day = "Dydd Mercher";
        }
        if (Day == "Thursday"){
            Day = "Dydd Iau";
        }
        if (Day == "Friday"){
            Day = "Dydd Gwener";
        }
        if (Day == "Saturday"){
            Day = "Dydd Sadwrn";
        }
        if (Day == "Sunday"){
            Day = "Dydd Sul";
        }
        if (Month == "January"){
            Month = "Ionawr";
        }
        if (Month == "Febuary"){
            Month = "Chwefror";
        }
        if (Month == "March"){
            Month = "Mawrth";
        }

        if (Month == "April"){
            Month = "Ebrill";
        }
        if (Month == "May"){
            Month = "Mai";
        }
        if (Month == "June"){
            Month = "Mehefin";
        }
        if (Month == "Jully"){
            Month = "Gorffennaf";
        }
        if (Month == "August"){
            Month = "Awst";
        }
        if (Month == "September"){
            Month = "Medi";
        }
        if (Month == "October"){
            Month = "Hydref";
        }
        if (Month == "November"){
            Month = "Tachwedd";
        }
        if (Month == "December"){
            Month = "Rhagfyr";
        }
        System.out.println(Date + " " + Day + " " + Month);
    }
}

0 个答案:

没有答案