Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop your program according the pseudo code given in class. of 3 -ZOOM + 1. Copy instructors JulianDate class from CSUSs Canvas into your working

Develop your program according the pseudo code given in class. of 3 -ZOOM + 1. Copy instructors JulianDate class from CSUSs 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 instructors 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 Jgrasps run argument as an option, if an user chooses to do so.\" v:shapes=\"Picture_x0020_139\">

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 => { printMonth(month); } } //second method read a year //print the calendar of the year //label the calendar of the year //prints months

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 ++n4; } int n5 = n2; if (n2 > 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.

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions