Question: HELPPPPPPP! This assignment will focus on the use of functions and the passing of parameters. You are to construct a C program, date.c, which performs

HELPPPPPPP!

This assignment will focus on the use of functions and the passing of parameters. You are to construct a C program, date.c, which performs each of the following operations:

Converts a calendar date into a Julian date.

Converts a Julian date into a calendar date.

Computes the number of days between any two calendar dates.

A calendar date is simply a date that contains a year, month, and day and a Julian date is an integer between 1 and 366, inclusive, which tells how m any days have elapsed since the first of January in the current year (including the day for which the date is calculated). For example, calendar date 4/12/2008 is equivalent to Julian date 103, 2008.

Write a C program to contain a selection menu (hint: think do - while loop) that allows the user to choose one of the options. An illustration is given below:

DATE SELECTION MENU

1) Convert calendar date into Julian date

2) Convert Julian date into calendar date

3) Compute days between two calendar dates

4) Exit program

ENTER SELECTION (1-4):

Be sure your program contains separate functions for each of the required operations, passing parameters as necessary. Remember that no global variables are allowed in your program except for the file pointer. You should create at least the following functions for your program:

display Menu displays selection menu and prompts user for selection

get Calendar Date prompts and gets calendar date from user

get Julian Date prompts and gets Julian date from user

to Calendar converts Julian date into calendar date

to Julian converts calendar date into Julian date

days Between Dates calculates the number of days between two calendar dates

Hint to compute the number of days between two calendar dates: For each date, figure out the number of days since January 1, 1900 and then subtract.

For this assignment we will define a leap year as any year that is evenly divisible by 4 but not 100, except that years divisible by 400 are leap years. Heres a function you can use to calculate leap years. Try and work through its details.

int isLeapYear(int year) {

return ((!(year % 4) && year % 100) || !(year % 400));

}

Test data for the lab is given below. Be sure to turn in output for each of the test data provided below. The information appearing in the parentheses after each piece of the test data are the correct (hopefully) solutions. You may use these solutions to test your program on the supplied test data. Ultimately, however, your program should be able to run on any valid data.

Convert Calendar Date into Julian Date

11

15

1922

319, 1922

2

29

1984

60, 1984

7

7

2000

189, 2000

Convert Julian Date into Calendar Date

53

1947

2/22/1947

211

1995

7/30/1995

360

2006

12/26/2006

Compute Number of Days between Two Calendar Dates

5

12

1949

8

16

1900

17801

12

15

1985

3

1

1986

76

1

1

1900

7

1

1993

34155

Be sure to turn in output for each of the test data provided above. The information appearing in the parentheses after each piece of the test data are the correct (hopefully) solutions. You may use these solutions to test your program on the supplied test data. Ultimately, however, your program should run on any valid data.

Extra Credit

Given a calendar date and the number of days until some future event, determine the calendar date of the future event.

Given any calendar date, determine its corresponding day of the week. You may assume that January 1, 1990 was a Monday. (Hint: think mod 7).

Use the following extra credit test data:

Compute Future Date

5

16

1947

2376

(11/16/1953)

2

12

1912

6000

(7/17/1928)

12

15

1933

2345

(5/17/1940)

Compute day of week

12

31

1900

(Monday)

4

18

1977

(Monday)

8

1

1932

(Monday)

11

30

1947

(Sunday)

12

31

1986

(Wednesday)

12

31

1988

(Saturday)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!