Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We want to track weather conditions during the past year and have designated eac

ID: 3854693 • Letter: W

Question

We want to track weather conditions during the past year and have designated each day as either rainy ('R'), cloudy ('C'), sunny ('S') or Armegeddon ('A').

Write a program that stores this information in s 3x30 array of characters, where the row indicates the month and the column indicates the day of the month. Note no data is being captured for the 31st of any month.

This program will read the data in from a file called RainOrShine.txt. From this data it you should create a report that displays, for each month, and for the whole three month period, how many days were rainy, how many were cloudy, and how many were sunny. It should also report which of the months had the largest number of rainy days and which month had the worst Armageddon factor.

Explanation / Answer

using namespace std;

int main()

{

const int MONTH = 3;

const int DAY = 30;

char name[MONTH][DAY] = {"June", "July", "August"};

char rain = 'R';

char sun = 'S';

char cloud = 'C';

int day = 0;

int months = 0;

int rainy = 0;

int cloudy = 0;

int sunny = 0;

ifstream datafile;

cout << " Rain or Shine ";

cout << "--------------- ";

datafile.open("file.txt");

if (!datafile)

cout << "Error opening data file. ";

else

{   cout << "Weather Report ";

for (months = 0; months < MONTH; months++)

{

    for (day = 0; day < DAY; day++)

    {

        cout << name[months][day];

       datafile >> name[months][day];

        if (name[months][day] == 'R')

            rainy++;

        else if (name[months][day] == 'S')

            sunny++;

        else if (name[months][day] == 'C')

            cloudy++;

    }

    cout << endl;

    cout << " Total rainy days: " << rainy << endl;

    cout << " Total sunny days: " << sunny << endl;

    cout << " Total cloudy days: " << cloudy << endl << endl;1

}

datafile.close();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote