For this assignment you are expected to submit the following two files: 1. ????â„Ž??????â„Ž??????. â„Ž 2. ????â„Ž??????â„Ž??????. ??? You...

90.2K

Verified Solution

Question

Programming

For this assignment you are expected to submit the following twofiles:

1. ????â„Ž??????â„Ž??????. â„Ž
2. ????â„Ž??????â„Ž??????. ???

You are being asked to write a class for simple weather datastorage. Each instance of the class will hold data for
exactly one month (30 days). Each day’s weather will be classifiedas either rainy (‘R’), cloudy (‘C’), or sunny (‘S’).
To achieve this, your class will contain a character array oflength 30. The class will provide three functions to
return the number of rainy, cloudy, and sunny days in thatmonth.

Name your class \"MonthlyWeatherData\"; separate declaration fromthe implementation (i.e. Header and CPP files).
The class has the following members:
1. monthName, a private member of type string
2. arrMonth, a private member array of type char of size 30.
3. Non‐default constructor which receives two parameters, a stringand a char array. The constructor will copy the
array’s content from the parameter array to the member variablearrMonth.
4. destructor. Leave the destructor empty.
5. getMonthName, returns the value of the variable monthName
6. numberOfRainyDays, this method returns the number of days in themonth designated with the letter R
7. numberOfSunnyDays, this method returns the number of days in themonth designated with the letter S
8. numberOfCloudyDays, this method returns the number of days inthe month designated with the letter C
9. toVector, this method returns a copy of the array arrMonth inthe form of a vector pointer. The method’s return
type is vector*
******Note:******
Use the provided test class to test your implementation. Don notmodify this code and do not submit it with
your solution. Your submission should only contain the header andCPP files of the class.
******************

// ***
// Do not modify this file
// ***

#include
#include \"MonthlyWeatherData.h\"

using namespace std;

// ***  Do not modify this file *****


void printStats(const MonthlyWeatherData *monthData) {

   cout << \"Status for the month of: \" <getMonthName() << endl;
   cout << \" Cloudy Days: \" <numberOfCloudyDays() << endl;
   cout << \" Rainy Days: \" <numberOfRainyDays() << endl;
   cout << \" Sunny Days: \" <numberOfSunnyDays() << endl;
}

int main() {

   // ***  Do not modify this file *****

   char arr0[] = { 'S', 'S', 'S', 'S', 'S', 'C', 'C','C', 'S', 'C', 'R', 'S',
           'R', 'R', 'S','S', 'R', 'S', 'S', 'R', 'C', 'C', 'R', 'C', 'C',
           'R', 'R', 'R','C', 'C', 'C', 'S', 'S', 'R', 'C', 'R' };
   char arr1[] = { 'R', 'R', 'C', 'R', 'R', 'C', 'C','R', 'C', 'S', 'S', 'S',
           'C', 'S', 'S','R', 'R', 'C', 'S', 'C', 'C', 'C', 'S', 'S', 'C',
           'C', 'C', 'S','S', 'C', 'C', 'C', 'C', 'C', 'C', 'C' };
   char arr2[] = { 'C', 'R', 'C', 'C', 'C', 'C', 'C','R', 'S', 'C', 'R', 'R',
           'S', 'S', 'S','R', 'R', 'S', 'S', 'S', 'S', 'C', 'S', 'R', 'S',
           'S', 'S', 'R','C', 'R', 'S', 'S', 'R', 'R', 'S', 'S' };
   char arr3[] = { 'C', 'C', 'S', 'S', 'R', 'R', 'C','C', 'C', 'S', 'R', 'S',
           'C', 'C', 'C','C', 'R', 'C', 'R', 'R', 'R', 'R', 'C', 'C', 'R',
           'R', 'S', 'R','C', 'C', 'C', 'S', 'R', 'C', 'R', 'R' };

   MonthlyWeatherData *one = newMonthlyWeatherData(\"January\", arr0);
   MonthlyWeatherData *two = newMonthlyWeatherData(\"February\", arr1);
   MonthlyWeatherData *three = newMonthlyWeatherData(\"March\", arr2);
   MonthlyWeatherData *four = newMonthlyWeatherData(\"April\", arr3);

   printStats(one);
   printStats(two);
   printStats(three);
   printStats(four);

   vector *vec = one->toVector();

   cout << \"Deallocating MonthlyWeatherDatainstances\" << endl;

   delete one;
   delete two;
   delete three;
   delete four;

   cout << \"Weather data for January usingvector\" << endl;

   for (int i = 0; i < 30; ++i)
       cout << (*vec)[i] << \"\";

   cout << endl;

   delete vec;

   return 0;
}

Answer & Explanation Solved by verified expert
3.8 Ratings (604 Votes)
Both required files code are attached below along with    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students