“Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function. It MUST BE of this form: int daysIntoYear ( int year, int month, int day ) ; In terms of "Days Into Year," how many days are we into the year based on a given date? For example, January 1 is 1 day into the year.   Please have the code display 12 test cases with the result from the function, and the number of days into the year from some other source.   So you can hand calculate the days into the year or use an internet web page.   The typical output might look like this: (Please make the format better but be sure to automatically calculate agree/disagree column) You must include a leap year function that returns a bool and takes as a parameter the year. This function must be used in your code.      Year    Month    day    Days Into Year     Value expected       Agree/Disagree 2020     1           1               1                     1                            agree 2020     1          20            20                   20                           agree 2020     3         10           70                   70                           agree 2021     3        10            69                  69                               agree 2000     3        10           70                   70                             agree 2100    3         10            69                 69                             agree   etc.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section: Chapter Questions
Problem 3PP
icon
Related questions
Question

“Days Into Year (C++)”

By using my code (photo is attached), implement a Days Into Year function.

It MUST BE of this form:

int daysIntoYear ( int year, int month, int day ) ;

In terms of "Days Into Year," how many days are we into the year based on a given date? For example, January 1 is 1 day into the year.  

Please have the code display 12 test cases with the result from the function, and the number of days into the year from some other source.  

So you can hand calculate the days into the year or use an internet web page.  

The typical output might look like this:

(Please make the format better but be sure to automatically calculate agree/disagree column)

You must include a leap year function that returns a bool and takes as a parameter the year. This function must be used in your code.   

 

Year    Month    day    Days Into Year     Value expected       Agree/Disagree

2020     1           1               1                     1                            agree

2020     1          20            20                   20                           agree

2020     3         10           70                   70                           agree

2021     3        10            69                  69                               agree

2000     3        10           70                   70                             agree

2100    3         10            69                 69                             agree

 

etc.   

Year Month day Days Into Year Value expected
Agree/Disagree
2020
1
1
1
1
agree
2020
1
20
20
20
agree
2020
3
10
70
70
agree
2021
3
10
69
69
agree
2000
3
10
70
70
agree
2100 3
10
69
69
agree
etc.
Transcribed Image Text:Year Month day Days Into Year Value expected Agree/Disagree 2020 1 1 1 1 agree 2020 1 20 20 20 agree 2020 3 10 70 70 agree 2021 3 10 69 69 agree 2000 3 10 70 70 agree 2100 3 10 69 69 agree etc.
1
#include <iostream>
2
#include<math.h>
3 using namespace std;
int main()
int YYYY,MM, DD;
int days=0;
int Day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
4.
5- {
7
cout<<"Enter the date in YYYY-MM-DD format:
cin>>YYYY>>MM>>DD;
MM=abs(MM);
DD=abs(DD);
if(MM<1&&MM>12){
cout<<"Invalid Month!";
exit(0);
}
if((YYYY%400==0) ||(YYYY%4==0 && YY%100!=0))
Day[2]=29; //if year is leap year then add 1 more into feb days
for(int i=0;i<MM;i++)
days+=Day[i];
days=days+DD;
cout<<"Number of days= "<<days;
10
11
12
13
14
15
16
17
18
19
20
21
22 }
Transcribed Image Text:1 #include <iostream> 2 #include<math.h> 3 using namespace std; int main() int YYYY,MM, DD; int days=0; int Day[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 4. 5- { 7 cout<<"Enter the date in YYYY-MM-DD format: cin>>YYYY>>MM>>DD; MM=abs(MM); DD=abs(DD); if(MM<1&&MM>12){ cout<<"Invalid Month!"; exit(0); } if((YYYY%400==0) ||(YYYY%4==0 && YY%100!=0)) Day[2]=29; //if year is leap year then add 1 more into feb days for(int i=0;i<MM;i++) days+=Day[i]; days=days+DD; cout<<"Number of days= "<<days; 10 11 12 13 14 15 16 17 18 19 20 21 22 }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning