Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. Objective 0 Create a piogram that will ask for a birthdate and calculate the age in days. 0 Work with symbolic constants, conversion [format]
. Objective 0 Create a piogram that will ask for a birthdate and calculate the age in days. 0 Work with symbolic constants, conversion [format] specifiers, and puts() function. . Related SLO: 0 Develop properly stiuctured multifile programs with automatic compilation. - instructions 0 For file management purposes, you may want to create separate folders for each programming assignment. 0 Create a program named tastnameFir'stnameBS.c_. that does the following: 1. Ensure your plogram is able to use the custom getdoub1e() function from the example code. I To use the getdouble() function, you need the files: gecdeujle . c_. get double . l", and nakefile-CCLIJLe. - Download each file by right-clicking on each link above and Save link As... - After downloading each file to your computer, upload it to your uhunix account and ensure the files are in the same directory as your LastnameFirstnameeS. c program. - Use emacs to edit make'Fileedouble so that it will compile and link getdouble .c, getdouble .h, and LastnameFir'stnameBE. c. In other words, you want to replace all instances of inputdouble with LastnameFirstnameOS. - Save makefile- double. 2. Add the following include statement at the top of your program: #include "ge'tdouble.h" 3. Define and use at least 1 symbolic constant with #de'fine I It is up to you to decide what you want to be a constant. You may need to come back to this bullet later. 4. Use at least1 put5(} function call. I It is up to you what you want to print using puts\". . Use int for all numeric variable types, this will make the calculations and output simpler. . Output a message telling the user what this program does. . Ask the user to enter a number representing the month, then the day, and then the year they were born. - Use separate prompts for each piece of information. - Use the custom getdoubleO function to get the information. Typecast the return value to store in your variables. For example: inputHonth = (int) getdouble(); S. Declare and initialize 3 variables to stole the cm ient date, one for the month, day, and year. I Use the assignment due date as the current date. - Do not prercalculate the amount of days to the current date, the variables should allow the current date to be easily changed for the future. 9. Display the current date. 10. Calculate the user's age in days. - Calculate the number of days since year 1 for todays date and the birthdate, then subtract the number of days since year 1 for the birthdate from the number of days since year 1 for today's date. - Age in Days = {sf of days since year 1 for current date} - (if of days since year 1 for birthdate) - Calculate the number of days since year 1 for the current date by: [1) multiplying the year by 365.25 to account for leap yeals every foul years, [2] subtlact one from the month (so September would be 9 - 1 = SJ and multiply this by 365.25!12.0_. and (3) adding both results to the day of the month. - li' of days since year 1 for current date = (current year\" 365.25) + ((current month - 11" 36523110) + (current day) I Calculate the number of days since year 1 for the birthdate by: {1) multiplying the year by 365.25 to account for leap years every foul years, [2] subtract one from the month and multiply this by 365.25!12.01 and (3} adding both results to the day of the month. I if of days since year 1 for birthdate = {birth year " 365.25) + \"birth month - I} ' 365.25l12.0) + {birth day} 11. You can check your calculations by using this website: gs Cachlator I Set the Age at This Date to the due date of this assignment. - Don't worry if your calculations are off bya few days when comparing to the website, this is due to rounding. However, they should match the example output shown below. 12. Alternative Age Calculatol, sometimes the one above goes offline: age Calculato- I Set the Age at the Date of to the due date of this assignment. 13. Print out the number of days with an appropriate label. 14. [0PTi0NAL] When you display the user's age in days, if the age is greater than or equal 1000, put a comma in the 10005 place by separating the number into two parts using division and modulus by 1000. - In other words, the 1000's place is calculated by {totalDays ./ 1898). The first three digits are calculated Moo-r 14. [OPTIONAL] when you display the user's age in days, if the age is greater than or equal 1000, put a comma in the 10005 place by separating the number into two parts using division and modulus by 1000. - In other words, the 1000's place is calculated by {totalDays f 1888). The first three digits are calculated by (totalDays K 1888}. - To include extra zeroes on integers, use K. 3i precision as shown in '"o 'mat.t and demonstrated in the second example output. 15. Doublecheck that you used at Least 1 symbolic constant and 1 put.\" function call. 16. At the end of the main function, be sure to return 8;. - Moving forward, this applies to all assignments. regardless if it is stated in the instructions or not. - Since main is declared as an int function, it should return an int at some point. It is customary to return 0;. at the end of main. 0 is a value signaling that the program terminated successfully. Any non-zero value would indicate that the program was not successful or that an error occurred. 1?. Be sure to have a program description at the top and in-line comments. - Be sure to have read through the isigrmen: My for this class. . Example Output K make -f makefile-double K .Iprogram This program will calculate your age in days. Enter the month you were born (1-12): 1 Enter the day you were born: 1 Enter the year you were born: 2828 Today's date is: 9f13f2822 Birthday is: 1f1!2828 Your age in days is: 986 K .Iprogram This program will calculate your age in days. Enter the month you were born (1-12): 12 Enter the day you were born: 12 Enter the year you were born: 2819 Today's date is: 9f13f2822 Birthday is: 12f12f2819 Your age in days is: 1,885 K .Iprogram This program will calculate your age in days. Enter the month you were born (1-12): ? Enter the day you were born: 38 Enter the year you were born: 1915 Today's date is: 9f13f2822 Birthday is: 7f38f19?5 Your age in days is: 1?,211 K .Iprogram This program will calculate your age in days. Enter the month you were born (1-12): 18 Enter the day you were born: 38 Enter the year you were born: 1958 Today's date is: 9f13f2822 Birthday is: 18f38f1958 Your age in days is: 26,251 . Hints o In my solution, I used the following: - 1 symbolic constant - 9 int variables - The Ki format specifier
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started