Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Calendar; public class PrintCalendar { private int year; //private final JulianDate jd = new JulianDate(); int printMonth; public static void main (String[] args) {

image text in transcribedimage text in transcribedimage text in transcribed

import java.util.Calendar;

public class PrintCalendar { private int year; //private final JulianDate jd = new JulianDate(); int printMonth; public static void main (String[] args) { int inputYear; //check program if an argument is passed from the command line if(args.length==0) { //if no argument is passed, then default the current year inputYear = Calendar.getInstance().get(Calendar.YEAR); } else { //if an argument is being passed, parse the string to an //integer and store as Input inputYear = Integer.parseInt(args[0]);; } //instantiate a new PrintCalendar object PrintCalendar myCal = new PrintCalendar (inputYear); //print the calendar myCal.printCal (); } //}

public PrintCalendar(int inputYear) { this.year = inputYear; } public void printCal() { //label the year System.out.printf("%13s ", this.year); //repeat 12 times to print a month for(int month = 1; month

public void printMonth(int month) { //labe the input of month //labe days of the week System.out.println(" Sun Mon Tue Wed Thu Fri Sat"); //prints days numbers 1 2 3 .. }

//third refinement //read a year //print the calendar of the year //label the year //repeat 12 times //print a month

public static boolean determineLeapYear(int year) { if((year % 400 = 0) || ((year % 4 == 0) && (year % 100 !=0))) { return true; } return false; }

//label the month //label days of the week //print days

public void printDayOfWeek () { System.out.println(" Sun Mon Tue Wed Thu Fri Sat"); }

//fifth //deterine number of days //position the 1st day //print days

public void printDayNumbers (int month) { }

//sixth //print a day public void getNumberOfDay (int month) { //switch statement that uses the month number to return the day switch (month) { case 1: System.out.printf(" %15s ", "January"); numberOfDay = 31; break; //february sometimes has 28 or 29 days case 3: System.out.rintf(" %15s ", "March"); numberOfDay = 31; break; case 4: System.out.printf(" %15s ", "April"); numberOfDay = 30; break; case 5: System.out.printf(" %15s ", "May"); numberOfDay = 31; break; case 6: System.out.printf(" %15s ", "June"); numberOfDay = 30; break; case 7: System.out.printf(" %15s ", "July"); numberOfDay = 31; break; case 8: System.out.printf(" %15s ", "August"); numberOfDay = 31; break; case 9: System.out.printf(" %15s ", "September"); numberOfDay = 30; break; case 10: System.out.printf(" %15s ", "October"); numberOfDay = 31; break; case 11: System.out.prntf(" %15s ", "November"); numberOfDay = 30; break; case 12: System.out.printf(" %15s ", "December"); numberOfDay = 31; break; } this.printDayOfWeek(); this.printDayNumbers(month); return numberOfDay; } private int getFebruaryDays() { if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) { return 29; } return 28; } } Above I have included what I have so far and I will include the Julian class as well.

public class JulianDate { public static int JGREG = 588829;

public static int toJulian(int n, int n2, int n3) { int n4 = n; if (n 2) { ++n5; } else { --n4; n5 += 13; } double d = Math.floor(365.25 * (double)n4) + Math.floor(30.6001 * (double)n5) + (double)n3 + 1720995.0; if (n3 + 31 * (n2 + 12 * n) >= JGREG) { int n6 = (int)(0.01 * (double)n4); d += (double)(2 - n6) + 0.25 * (double)n6; } return (int)Math.floor(d); } }

I need help with my program. I am trying to print the Calendar and it wont print.

Page > of 3 -ZOOM + 1. Copy instructor's JulianDate class from CSUS's Canvas into your working directory Note that the JulianDate class is not readable but it can be integrated with you program by placing it in the same directory as your source program under Jgrasp. The JulianDate class is used to determine the day of the week for the 1st day of January JulianDate JD-new JulianDate(); int date JD.toJulian(2018, 1,1); int dayofWeek- (date+1)%7;/ 0 means Sunday, 1 means Monday, etc 2. Develop your program according the pseudo code given in class. You are welcome to develop your program from afresh. You can name this program as PrintCalendar java. Additional Requirements 1. No arrays are allowed in this lab. 2. Your output should be closely similar to the output of the instructor's sample program (see below) 3. To determine whether a year is a leap year or not: a. If the year is a century year, the year must be divisible by 400 b. If the year is not a century year, the year only needs to be divisible by 4 4. To determine the current year, please use this code. currentYear Calendar.getInstance ) .get (Calendar.YEAR); noLe: please import java.util.Calendar 5. Allow user to input the selected year using Jgrasp's "run argument" as an option, if an user chooses to do so

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics And Quality Management Fundamental Tools

Authors: Joseph Nguyen

1st Edition

B0CNGG3Y2W, 979-8862833232

More Books

Students also viewed these Databases questions

Question

politeness and modesty, as well as indirectness;

Answered: 1 week ago