We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import javax.swing.*; public class lab3 { public static void main(String[] argv) { // 打开对话框 String dateString = JOptionPane.showInputDialog("输入日期"); // 获取年、月、日对应的字符串子串 // 这里的(0, 4)是一个前闭后开区间,即数学上的[0,4)位 String yearString = dateString.substring(0, 4); // 月份是第5、6位,对应的半开半闭区间是[5,7) String monthString = dateString.substring(5, 7); // 日期是第8、9位,对应的半开半闭区间是[8,10) String dayString = dateString.substring(8, 10); // 将字符串转换成对应的整数 int year = Integer.parseInt(yearString); int month = Integer.parseInt(monthString); int day = Integer.parseInt(dayString); // 条件判断 if ((month == 12 && day <= 22) || (month == 1 && day <= 19)) { System.out.println("这是摩羯座 ♑️"); } else if ((month == 1 && day <= 20) || (month == 2 && day <= 28)) { System.out.println("这是水瓶座 ♒️"); } else if ((month == 2 && day <= 19) || (month == 3 && day <= 20)) { System.out.println("这是双鱼座 ♓️"); } else if ((month == 3 && day <= 21) || (month == 4 && day <= 20)) { System.out.println("这是牡羊座 ♈️"); } else if ((month == 4 && day <= 21) || (month == 5 && day <= 20)) { System.out.println("这是金牛座 ♉️"); } else if ((month == 5 && day <= 21) || (month == 6 && day <= 21)) { System.out.println("这是双子座 ♊️"); } else if ((month == 6 && day <= 22) || (month == 7 && day <= 22)) { System.out.println("这是巨蟹座 ♋️"); } else if ((month == 7 && day <= 23) || (month == 8 && day <= 22)) { System.out.println("这是狮子座 ♌️"); } else if ((month == 8 && day <= 23) || (month == 9 && day <= 22)) { System.out.println("这是处女座 ♍️"); } else if ((month == 9 && day <= 23) || (month == 10 && day <= 22)) { System.out.println("这是天秤座 ♎️"); } else if ((month == 10 && day <= 23) || (month == 11 && day <= 21)) { System.out.println("这是天蝎座 ♏️"); } else if ((month == 11 && day <= 22) || (month == 12 && day <= 21)) { System.out.println("这是射手座 ♐️"); } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: