Write a program that prints the calendar for a given year

Assignment Help Computer Engineering
Reference no: EM132106237

Problem: Write a program that prints the calendar for a given year. The user will be promoted to choose the calendar for the month or the year. If the year is selected, then the calendar for the given year will be displayed. If the month is selected then the user will be prompted to enter the month, then the calendar for the given month will be displayed.

Top down design: Break down the problem into sub problems and state what you will achieve for each of the sub problems First we need to break down into two sub problems.

Get the user's input

a. Read the input(year)

Print the calendar

Print the calendar for the year

a. Print the calendar for each month of the year

i. Print the title for each month in the year.

Print the month and the year

Print "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".

ii. Print the body for the month

Get the number of the days for each month of the year

Need to know if the year is a leap year or not. A year is a leap year if it is divisible by 400 or if the year is divisible by 4 but not divisible by 100

Get the number for the first day in the month. For example, November 1st was on a Saturday which is the 6th day of the week assuming that Sunday is the zero day of the week. To figure out which day is the first day of the month you need to do the following:

a. Calculate the total number of days since 1800 up to the month of the year that you are trying to print the calendar

Calculate the total number of days since 1800 up to one year prior to the given year. Note that you also need to check if the year is a leap year or not. For example, if the user enters 2014, we need to calculate how many days from 1800 to 2013. Need a for loop and in the for loop you need to check if the year is a leap year.

Add the total days from the beginning of the given year up to the month. For example, if we are trying to print the calendar for the March 2014, then we need to add the total number of days in Jan and Feb to whatever we calculated in i.

Whatever you get from ii add 3 to it (January

1800 was on a Wednesday) iv. Calculate the remainder of iii divided by 7, this result will tell you that first days of month is Sun or Mon or Tue or Wed or Thu or Fri or Sat.

Determine the date for thanksgiving for November.

Now that you know the number of the days in the month and the day for the first day of the month you can print the calendar.

Now you can write a method that accepts the number of the days in the month and the first day of the month, then print the body

1. If the first day of the month is for example on a Saturday which is the 6th day of the week then you need to output 5 blanks " ".

You start printing from 1 to the last day of the month.

Add appropriate codes in the main method to give the user the option of displaying the calendar for the year or the month. Based on the user's option display the result.

A program shell has been provided for you.

Here is a sample output

Here is the sample output:

Enter a valid year after 1800: 2006 Select one of the following options:

To get the month calendar press m or M

To get the calendar for the year enter y or Y

Enter your choice: n

Invalid choice

Do you have another year to print the calendar:yes/no-->yes Enter a valid year after 1800: 2006 Select one of the following options:

To get the month calendar press m or M

To get the calendar for the year enter y or Y

Enter your choice: m

*Enter the month of the year1..12-->90

*Enter the month of the year1..12-->56

*Enter the month of the year1..12-->5

May 2006

----------------------------

Sun Mon Tue Wed Thu Fri Sat

1 2 3 4 5 6

7 8 9 10 11 12 13

14 15 16 17 18 19 20

Reference no: EM132106237

Questions Cloud

What should be discussed with a doctor concerning the end : What should be discussed with a doctor concerning the end of life care for an individual with who has no families?Would the doctors abide by the patients decisi
What considerations could be discussed concerning : What considerations could be discussed concerning on the end of life care for individuals with a family?
Describe a function that will prompt the user to enter : Describe a function that will prompt the user to enter 50 whole numbers and count how many even and odd numbers were entered.
What is the research on the topic of gender universals : What is the research on the topic of gender universals when it come to emotion, including cross-cultural researches?
Write a program that prints the calendar for a given year : Write a program that prints the calendar for a given year. The user will be promoted to choose the calendar for the month or the year.
Determine the correct inventory amount on december : Josef received goods costing $41,900 on January 2 that were shipped FOB destination on December 29. Determine the correct inventory amount on December 31
Draw a rectangle as a rectangle and as a polygon : Draw a rectangle as a Rectangle and as a Polygon. Make the lines of the Polygon yellow and the lines of the Rectangle green.
Calculate and display a square matrix multiplication table : A program will calculate and display a square matrix multiplication table. For instance a sample output for a 4x4 table is listed below.
Experience of emotions by women and men : According to recent research on the experience of emotions by women and men, what is the situation that best predicts the experience of negative emotions

Reviews

Write a Review

Computer Engineering Questions & Answers

  Define the thread hello program

For the thread Hello program in Figure ??, when pthread join() returns for thread ii, in which of the states shown in Figure is thread ii?

  Write mips assembly language program to recursively compute

Write a MIPS assembly language program to recursively compute the nth term of Perrin's sequence. n will be input from the keyboard.

  Design a logical and physical topographical layout

Design a logical and physical topographical layout of the current and planned network through the use of graphical tools in Microsoft Word or Visio, or an open source alternative such as Dia.

  Design a test to determine whether or not they are random

Use a linear congruential generator with parameters of your own choosing to generate 1000. Design and apply a test to determine whether or not they're random.

  A security engineer for a hospital group based in cincinnati

a security engineer for a hospital group based in Cincinnati, OH. Your group has just acquired a small hospital in Alba

  Tabulate the pal programming table for the circuit

The following is a truth table of a 3-input, 4-output combinational circuit. Tabulate the PAL programming table for the circuit and mark the fuses to be blown.

  List differences between linked list and array structure

List three differences between Linked List structure and Array structure? Include the differences of How we add/remove elements in each.

  Define the matlab function

Suppose S(x) is a cubic spline interpolant of the data (Xl, yl), ... , (xn, Yn) obtained using spline. Write a MATLAB function d3 - MaxJump(S) that returns.

  What are all permutations of the four-letter word beat

What are all permutations of the four-letter word beat? Why isn't it easy to develop an iterative solution for the permutation generator?

  Make a clear button that will clear both text boxes

Your employer has requested the growth of a software application to calculate the area of a circle. The application must accept only one value (i.e., the radius), and it must display the result in decimal value.

  Describe the classes of executive decision making

Executive information system. Definition,properties,features, properties, advantages, who/what it's used for?

  Identify the manufacturer of your computer

Identify the manufacturer of your computer. Identify the file system of two different types of removable media (such as a CD, DVD, USB, or flash memory card).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd