Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Date Lab: help with c programming, below is the instructions. This assignment will focus on the use of functions and the passing of parameters. You

Date Lab: help with c programming, below is the instructions.

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 calender date into a Julian date.

Converts a Julian date into a calender date.

Computes the number of days between and two calender dates.

A calender 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 many days habe elapsed since the first of January in the current year (including the day for which the date is calculated). For example, calender date 4/12/2008 is equivalent to Julian date 103, 2008.

Your program should 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 calender date into Julian date

2) Convert Julian date into calender date

3) Compute days between two calender 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:

displayMenu - displays selection menu and promps user for selection

getCalenderDate - prompts and gets calender date from user

getJulianDate - prompts and gets Julian date from user

toCalender - converts Julian date into calender date toJulian converts calender date into Julian date

daysBetweenDates - calculates the number of days between two calender dates

Hint to compute the number of days between two calender 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 divisble by 4 but not 100, except that years divisble by 400 are leap years. Here's 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)); }

Remember that the main () function should appear as the first function in the program. Be sure to use function prototypes for each of the functions that are used in your program.

Test data for the lab is given below.

Convert Calender Date Into Julian Date:

11 15 1922 (319, 1922)
2 29 1984 ( 60, 1984)
7 7 2000 (189, 2000)

Convert Julian Date into Calender Date:

53 1947 ( 2/22/1947)
211 1995 ( 7/30/1995)
360 2006 (12/26/2006)

Compute number of days between two calender dates:

5 12 1949 8 16 1900 (17801)
12 15 1985 3 1 1986 (76)
1 1 1900 7 7 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 be able to run on any valid data.

Extra Credit:

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

Given any calender 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)

Output from your program should be sent to the terminal window (your screen) as well as the requested csis.txt output file. Be sure to read the document on Capturing Program Output. Be sure to include the csis.txt output file in your zip archive.

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What is the purpose of an idea bank?

Answered: 1 week ago

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago