改错,java.说出具体错误,编译过了给分。
importjava.util.*;importjava.util.Scanner;publicclassRun{publicstaticvoidmain(Stringa...
import java.util.*;
import java.util.Scanner;
public class Run{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
Scanner year=new Scanner(System.in);
Scanner month=new Scanner(System.in);
System.out.println("要输出的年月:"+year+" "+month);
if((year%4==0&&year%100!=0)||year%400==0)
{
int[] day_Month={31,29,31,30,31,30,31,31,30,31,30,31};
}
else int[] day_Month={31,28,31,30,31,30,31,31,30,31,30,31};
calendar.setTime(new Date());
long time_now=calendar.getTimeInMills();
calendar.set(year,month,1);
long time_in=calendar.getTimeInMills();
int day=(time1-time2)/(1000*60*60*24);
String now_Day_Week=String.ValueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);
String now_DayOfWeek=Integer.parseInt(now_Day_Week);
int remind1=day%7;
int week=(remind+now_DayOfWeek)%7;
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.ValueOf(n);
System.out.println("%4n%4n%4n%4n%4n%4n%4n\n"'日','一','二','三','四','五','六');
for(int k=0;k<a.length;k++)
{
if(k%7==0&&k!=0)
System.out.printf("\n");
else
System.out.println("%5s",a[k]);
}
}
}
说下题目吧,输出某年某月的日历页。我的思路是:利用Date里的函数得到当前电脑时间,进而算出要输出的那个月1号是星期几。然后赋值输出。。。也许能帮助改错着更好的阅读。 展开
import java.util.Scanner;
public class Run{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
Scanner year=new Scanner(System.in);
Scanner month=new Scanner(System.in);
System.out.println("要输出的年月:"+year+" "+month);
if((year%4==0&&year%100!=0)||year%400==0)
{
int[] day_Month={31,29,31,30,31,30,31,31,30,31,30,31};
}
else int[] day_Month={31,28,31,30,31,30,31,31,30,31,30,31};
calendar.setTime(new Date());
long time_now=calendar.getTimeInMills();
calendar.set(year,month,1);
long time_in=calendar.getTimeInMills();
int day=(time1-time2)/(1000*60*60*24);
String now_Day_Week=String.ValueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);
String now_DayOfWeek=Integer.parseInt(now_Day_Week);
int remind1=day%7;
int week=(remind+now_DayOfWeek)%7;
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.ValueOf(n);
System.out.println("%4n%4n%4n%4n%4n%4n%4n\n"'日','一','二','三','四','五','六');
for(int k=0;k<a.length;k++)
{
if(k%7==0&&k!=0)
System.out.printf("\n");
else
System.out.println("%5s",a[k]);
}
}
}
说下题目吧,输出某年某月的日历页。我的思路是:利用Date里的函数得到当前电脑时间,进而算出要输出的那个月1号是星期几。然后赋值输出。。。也许能帮助改错着更好的阅读。 展开
展开全部
import java.util.*;
import java.util.Scanner;
public class Run{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
//Scanner year=new Scanner(System.in);
//Scanner month=new Scanner(System.in);//用Scanner类nextInt()方法获得下一个输入的整数
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
int month = scanner.nextInt();
System.out.println("要输出的年月:"+year+" "+month);
int[] day_Month;//变量要定义在if语句外,定义在if语句内的变量为局部变量,if语句之外不能调用到
if((year%4==0&&year%100!=0)||year%400==0)
{
day_Month=new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
}
else day_Month=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
calendar.setTime(new Date());
long time_now=calendar.getTimeInMillis();//getTimeInMills()写错了,应改为getTimeInMillis()
calendar.set(year,month,1);
long time_in=calendar.getTimeInMillis();
int day=(int)(time_now-time_in)/(1000*60*60*24);//time1、time2未定义
String now_Day_Week=String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);//ValueOf()写错,改为valueOf()
int now_DayOfWeek=Integer.parseInt(now_Day_Week);//now_DayOfWeek类型已转为int,不是原来的String类型
int remind1=day%7;
int week=(remind1+now_DayOfWeek)%7;//变量名写错不是remind
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.valueOf(n);//ValueOf()写错,改为valueOf()
System.out.printf("%4n%4n%4n%4n%4n%4n%4n\n",'日','一','二','三','四','五','六');//println()方法输出的是String类型,故改为printf()
for(int k=0;k<a.length;k++)
{
if(k%7==0&&k!=0)
System.out.printf("\n");
else
System.out.printf("%5s",a[k]);//println()方法输出的是String类型,故改为printf()
}
}
}
import java.util.Scanner;
public class Run{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
//Scanner year=new Scanner(System.in);
//Scanner month=new Scanner(System.in);//用Scanner类nextInt()方法获得下一个输入的整数
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
int month = scanner.nextInt();
System.out.println("要输出的年月:"+year+" "+month);
int[] day_Month;//变量要定义在if语句外,定义在if语句内的变量为局部变量,if语句之外不能调用到
if((year%4==0&&year%100!=0)||year%400==0)
{
day_Month=new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
}
else day_Month=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
calendar.setTime(new Date());
long time_now=calendar.getTimeInMillis();//getTimeInMills()写错了,应改为getTimeInMillis()
calendar.set(year,month,1);
long time_in=calendar.getTimeInMillis();
int day=(int)(time_now-time_in)/(1000*60*60*24);//time1、time2未定义
String now_Day_Week=String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);//ValueOf()写错,改为valueOf()
int now_DayOfWeek=Integer.parseInt(now_Day_Week);//now_DayOfWeek类型已转为int,不是原来的String类型
int remind1=day%7;
int week=(remind1+now_DayOfWeek)%7;//变量名写错不是remind
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.valueOf(n);//ValueOf()写错,改为valueOf()
System.out.printf("%4n%4n%4n%4n%4n%4n%4n\n",'日','一','二','三','四','五','六');//println()方法输出的是String类型,故改为printf()
for(int k=0;k<a.length;k++)
{
if(k%7==0&&k!=0)
System.out.printf("\n");
else
System.out.printf("%5s",a[k]);//println()方法输出的是String类型,故改为printf()
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
package com.xtkj.test;
import java.util.*;
public class Run{
public static void main(String args[]){
Calendar calendar=Calendar.getInstance();
Scanner scanner = new Scanner(System.in);
System.out.println("Input Year:");
int year = scanner.nextInt();
System.out.println("input Month");
int month = scanner.nextInt();
System.out.println("要输出的年月:"+year+" "+month);
calendar.setTime(new Date());
long time_now=calendar.getTimeInMillis();
calendar.set(year,month,1);
long time_in=calendar.getTimeInMillis();
int day=(int) ((time_now-time_in)/(1000*60*60*24));
String now_Day_Week=String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);
int now_DayOfWeek=Integer.parseInt(now_Day_Week);
int remind1=day%7; int week=(remind1+now_DayOfWeek)%7;
int[] day_Month = {};
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.valueOf(n);
System.out.printf("%4n%4n%4n%4n%4n%4n%4n\n",'日','一','二','三','四','五','六');
for(int k=0;k<a.length;k++) {
if(k%7==0&&k!=0) System.out.printf("\n");
else System.out.printf("%5s",a[k]);
} } }
//楼主是自己写的吗,错误很多
import java.util.*;
public class Run{
public static void main(String args[]){
Calendar calendar=Calendar.getInstance();
Scanner scanner = new Scanner(System.in);
System.out.println("Input Year:");
int year = scanner.nextInt();
System.out.println("input Month");
int month = scanner.nextInt();
System.out.println("要输出的年月:"+year+" "+month);
calendar.setTime(new Date());
long time_now=calendar.getTimeInMillis();
calendar.set(year,month,1);
long time_in=calendar.getTimeInMillis();
int day=(int) ((time_now-time_in)/(1000*60*60*24));
String now_Day_Week=String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)-1);
int now_DayOfWeek=Integer.parseInt(now_Day_Week);
int remind1=day%7; int week=(remind1+now_DayOfWeek)%7;
int[] day_Month = {};
String a[]=new String[week+day_Month[month]];
for(int i=0;i<week;i++)
a[i]=" ";
for(int j=week,n=1;j<week+day_Month[month];j++)
a[j]=String.valueOf(n);
System.out.printf("%4n%4n%4n%4n%4n%4n%4n\n",'日','一','二','三','四','五','六');
for(int k=0;k<a.length;k++) {
if(k%7==0&&k!=0) System.out.printf("\n");
else System.out.printf("%5s",a[k]);
} } }
//楼主是自己写的吗,错误很多
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Scanner scanner = new Scanner(System.in);
System.out.println("Input Year:");
int year = scanner.nextInt();
System.out.println("input Month");
int month = scanner.nextInt();
System.out.println("Input Year:");
int year = scanner.nextInt();
System.out.println("input Month");
int month = scanner.nextInt();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
路过。。。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询