“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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education