我是一名新的 Java 程序员,正在研究先前的建议,以生成一个可以接受 1-365 整数并给出月份和日期的计算器。我不确定如何将每个月解析为单独的变量。完全卡住了。任何帮助将不胜感激。
import java.util.Scanner;
public class principal {
public static void maxn(String[] args) {
Scanner input = new Scanner(System.in);
int x = 0;
int date;
if (x < 30) {
month = "January";
date = x;
System.out.println(month + " " + day);
} else
x += 31;
if (31 < x < 58){
String month = "February";
day -= x;
if (31 < x < 58 < 89) {
month = "March"
day -= x;
if (31 < x < 58 < 89 < 120) {
month = "April"
day -= x;
if (31 < x < 58 < 89 < 120 < 150) ;
{
month = "May"
day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180) ;
{
month = "June"
day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211) {
month = "July"
day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211 < 242) {
month = "August"
day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211 < 242 < 273) {
month = "September" day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211 < 242 < 273 < 303) {
month = "October" day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211 < 242 < 273 < 303 < 334) {
month = "November"
day -= x;
if (31 < x < 58 < 89 < 120 < 150 < 180 < 211 < 242 < 273 < 303 < 365) {
month = "December"
day -= x;
}
}
}
}