This is what I have so far include include using namespace s

This is what I have so far:

#include <iostream>
#include<string>
using namespace std;
int main()
{

string Month[]= {\"January\", \"February\", \"March\", \"April\",
\"May\", \"June\", \"July\",\"August\", \"September\",
\"October\",\"November\", \"December\"};
   int Days[]={31, 28, 31, 30,31, 30, 31, 31,30, 31, 30, 31};
  
   for(int count=0; count<12; count++)
   {
       cout<<Month[count]<<\" has \"<<Days[count]<<\" days.\"<<endl;
   }
   system (\"pause\");
   return 0;
}

CSC 1700 ARRAY TASKS Task 1: Using the Months Array Example demonstrated in class to day, modify the code such that it displays as output the following: January has 31 days February has 28 days (Then continue printing this pattern out for the rest of the year months until) December has 31 days is printed. Hint: You may need to set up another array with the month names data Task 2: Modify this code further such that it displays also, \"February has 29 days in a leap year\". Task 3: odify the code further such that it adds up the number of days in a year i.e. values stored in the days [MONTHs] array and then display the total of a. How many days in the regular year b. How many days in a Leap year

Solution

#include <iostream>
#include<string>
using namespace std;
int main()
{

string Month[]= {\"January\", \"February\", \"March\", \"April\",
\"May\", \"June\", \"July\",\"August\", \"September\",
\"October\",\"November\", \"December\"};
int Days[]={31, 28, 31, 30,31, 30, 31, 31,30, 31, 30, 31};
  
for(int count=0; count<12; count++)
{
cout<<Month[count]<<\" has \"<<Days[count]<<\" days.\"<<endl;
}
//printing days in february in a leap year
cout<<Month[1]<<\" has \"<<Days[1]+1<<\" days in a leap year.\"<<endl;
  
int totaldays=0; //variable to store total days
//loop to calculate total days in a regular year
for(int count=0;count<12;count++){
totaldays=totaldays+Days[count];
}
//print days in a regular year
cout<<\"Days in the regular year : \"<<totaldays<<endl;
//print days in a leap year
cout<<\"Days in the leap year : \"<<totaldays+1<<endl;
  
// system (\"pause\");
return 0;
}

/******OUTPUT*******
January has 31 days.
February has 28 days.   
March has 31 days.
April has 30 days.
May has 31 days.
June has 30 days.   
July has 31 days.   
August has 31 days.   
September has 30 days.
October has 31 days.
November has 30 days.   
December has 31 days.   
February has 29 days in a leap year.
Days in the regular year : 365
Days in the leap year : 366
*******OUTPUT********/
/* Note:I have added the required changes with comments for the understaanding,Code has been tested on g++ compiler,please do ask in case of any doubt,Thanks.*/

This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\
This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site