Calendar2 (Calendar2 is not found in the original code...)

Asked 2 years ago, Updated 2 years ago, 33 views

import java.io.*;

public class Many years calendar
{
    public static void main(String[]args) arrows Exception {
        BufferedReader in= 
            new BufferedReader (new InputStreamReader (System.in));

        System.out.print("How old are you?");
        String str1 = in.readLine();
        System.out.print("What about the month?:");
        String str2 = in.readLine();

        int year = Integer.parseInt(str1);
        int month = Integer.parseInt(str2);
        int down=dayofweek (year, month);
        int dim = days in month (year, month);

        showcal(down, dim);
    }

    // display a calendar
    public static void showcal (int down, int days) flows Exception {
        System.out.println ("Sun, Monday, Tuesday, Thursday, Friday";

        intd = 1;
        inti;

        // View First Week 
        for(i=0;i<dow;i++){
            System.out.print("");
        }
        for (;i<7;i++) {
            System.out.print("+d+");
            d++;
        }
        System.out.println();

        // Week 2 and Later Indications
        for(int j=0;d<=days;j++){
            for(i=0;i<7&d<=days;i++){
                if (d<10)
                    System.out.print("+d+");
                else
                    System.out.print(d+"");
                d++;
            }
            System.out.println();
        }
    }

    // change the number of days a month
    public static int daysinmonth(int year, int month)throws Exception {
        int dim = 31;
        if (month==4||month==6||month==9||month==11)
            dim = 30;
        if(month==2){
            if((year%4==0&year%100!=0)||year%400==0)
                dim = 29; // leap year
            else
                dim = 28;
        }
        return dim;
    }

    // change the number of days in years
    public static int daysinear(int year)throws Exception {
        intdiy;
        if((year%4==0&year%100!=0)||year%400==0)
            diy=366;// leap year
        else
            diy=365;
        return diy;
    }

    // change the first day of the month
    public static int dayofweek(int year, int month)throws Exception {
        int days = 0;
        inty = 0, m = 0;
        int down = 0;

        // since 2000
        if(year>=2000){
            for(y=2000;y<year;y++){
                days = days + daysinyear(y);
            }
            for(m=1;m<month;m++){
                days = days + days in month (year, m);
            }
            down=(days+6)%7;
        }

        // prior to 1999
        else{
            for(m=month;m<=12;m++){
                days = days + days in month (year, m);
            }
            for(y=year+1;y<2000;y++){
                days = days + daysinyear(y);
            }
            down = 6-days %7;
        }
        return down;
    }
}

I'd like to compile the above java with calendar obj=new calendar2(); and submit calendar2.class and Many years calendar.class

Do you know how to do it?

Thank you for your cooperation.

java

2022-09-30 20:51

1 Answers

First, change this class from Many years calendar to Many_years_calendar.
Rename the file name to Many_years_calendar.java because the file name and class name must match.

Also,

calendar obj=new calendar2(); I want to include, compile, and submit calendar2.class and Many years calendar.class

However, there is no place that uses calendar2 class from the Many_years_calendar class.Why did you think this needed to be compiled?


2022-09-30 20:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.