++ Homework 2 Files
This commit is contained in:
parent
90652a17ce
commit
6269fbc4ce
10 changed files with 191 additions and 0 deletions
47
Homework2/seconds.c
Normal file
47
Homework2/seconds.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// header files
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
// local constants
|
||||
#define SECONDS_IN_YEAR 31449600
|
||||
#define SECONDS_IN_WEEK 604800
|
||||
#define SECONDS_IN_DAY 86400
|
||||
#define SECONDS_IN_HOUR 3600
|
||||
#define SECONDS_IN_MINUTE 60
|
||||
|
||||
#define TIME_CONSTANT_YEARS 3
|
||||
#define TIME_CONSTANT_WEEKS 6
|
||||
#define TIME_CONSTANT_DAYS 5
|
||||
#define TIME_CONSTANT_HOURS 2
|
||||
#define TIME_CONSTANT_MINUTES 5
|
||||
|
||||
/*
|
||||
Name: Seconds in TIME_CONSTANT
|
||||
Process: Calculates the amount of time in seconds that an amount of
|
||||
years/weeks/days/hours/minutes in total seconds.
|
||||
Function input/parameters: NONE
|
||||
Function output/parameters: NONE
|
||||
Function output/returned: NONE
|
||||
Device input/---: NONE
|
||||
Device output/---: NONE
|
||||
Dependencies: included by standard libraries
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
// define local variables
|
||||
int totalTime;
|
||||
// do calculations
|
||||
totalTime = (TIME_CONSTANT_YEARS * SECONDS_IN_YEAR) +
|
||||
(TIME_CONSTANT_WEEKS * SECONDS_IN_WEEK) +
|
||||
(TIME_CONSTANT_DAYS * SECONDS_IN_DAY) +
|
||||
(TIME_CONSTANT_HOURS * SECONDS_IN_HOUR) +
|
||||
(TIME_CONSTANT_MINUTES * SECONDS_IN_MINUTE);
|
||||
// display results
|
||||
printf("The total number of seconds in %d years, %d weeks, %d days, %d hours, and %d minutes is: %d seconds\n",
|
||||
TIME_CONSTANT_YEARS, TIME_CONSTANT_WEEKS, TIME_CONSTANT_DAYS,
|
||||
TIME_CONSTANT_HOURS, TIME_CONSTANT_MINUTES, totalTime);
|
||||
// return success
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue