Question
please hep me to modify the codes.i want the following codes in the following format date.h, time.h, weather.h, weather.cpp, vector.h, main.cpp,,,,add any if needed //header
please hep me to modify the codes.i want the following codes in the following format date.h, time.h, weather.h, weather.cpp, vector.h, main.cpp,,,,add any if needed
//header files #include
Wordcount++; if (index == 4) { FileDataList*list = new FileDataList(); list->WAST = Data[0]; list->S = Data[1]; list->SR= Data[2]; list->T = Data[3]; cout << list->WAST << " " << list->S <<" " << list->SR << " "<
class date //class date { public: //3 variables - day, month, year int day; int month; int year;
void setDay(int d) //setters { this->day = d; } void setMonth(int m) { this->month = m; }
void setYear(int y) { this->year = y; }
//getters int getDay() { return this->day; } int getMonth() { return this->month; } int getYear() { return this->year; } };
//class time
class time { public: //2 variables - minute, hour int minute; int hour; }; class weather : date //class weather inherited from date { date d; FileDataList *list; float wSpeed; float temperature; float solarRadiation; string token; int count = 1; bool match = false; public: //array to store months static const string months[12]; //function to show wind speed and temperature //passing month and year to it void showSandT(int m, int y) { list = head; while (list->next != NULL) { stringstream ss(list->WAST); while (getline(ss, token, '/')) { if (count == 1) { d.setDay(stoi(token)); count++; } else if (count == 2){ d.setMonth(stoi(token)); count++; } else if (count == 3){ count = 1; stringstream ss(token);
while (getline(ss, token, ' ')) { d.setYear(stoi(token)); break; } break; } } if (d.getMonth() == m) { if (d.getYear() == y) { for (int i = 0; i < 12; ++i) { if (i+1 == d.getMonth()) cout << " " << months[i]; }
cout << " " << d.getYear() << ": "; cout<< list->S << "km/h, " << list->T << " degree C"; match = true; } } if (match) return; list = list->next; } if (!match) { cout <<" "<< m << " " << y << ": No data"; } } //function to show wind speed and temperature using year void showSandT(int y) { match = false; list = head; cout << " " << y << endl; while (list->next!=NULL) { stringstream ss(list->WAST); while (getline(ss, token, '/')) { if (count == 1) { this->setDay(stoi(token)); count++; } else if (count == 2){ this->setMonth(stoi(token)); count++; } else if (count == 3){ count= 1; stringstream ss(token); while (ss, token, ' ') { this->setYear(stoi(token)); break; } break; } } if (getYear() == y) { for(int i = 0; i < 12; ++i) { if(i + 1 == getMonth()) cout << " " << months[i]; } cout << ": "; cout << list->S << "km/h, " << list->T << " degree C"<
//function to show all data fields using year
void showSTSR(int y) { match = false; list = head; cout << " "<< y << endl; while (list->next != NULL) { stringstream ss(list->WAST); while (getline(ss, token, '/')){ if (count == 1) { this->setDay(stoi(token)); count++;} else if (count == 2){ this->setMonth(stoi(token)); count++; } else if (count == 3){ count = 1; stringstream ss(token); while (getline(ss, token, ' ')) { this->setYear(stoi(token)); break; } break; } } if (getYear() == y) { for (int i = 0; i < 12; ++i) { if (i + 1 == getMonth()) cout << " " << months[i]; } cout << ", "; cout << list->S << ", " << list->T << ", " << list->SR << endl; match = true; } list = list->next; }
if (!match) { cout << " " << y << ": No data"; }}};
//initialising months array
const string weather::months[12] = { "January","February", "March","April", "May", "June","July", "August", "September", "October", "November", "December" }; //main function to test program //its provide menu for user int main() { //link list head to null head = NULL; //reading from file //which accepts file address readingFromFile("DataSample.txt"); //weather class object initialisation
weather *w = new weather(); int y; int m; string menue; int choice = 0; again: system("cls");
cout << "\t\t\t***Menu***" << endl; cout << " 1.wind speed and temperature (year & month)"<< " 2.wind speed and temperature (year)" << " 3.solar radiation in kWh/m2 (year)" <<" 4.wind speed (km/h), temperature and total solar radiation in kWh/m2 (year)" <<" 5.Exit"<< endl; cout << " Enter Your Choice: "; cin >> choice; switch (choice) { case 1: cout << " Enter year(like 2020): "; cin >> y; cout << " Enter month(like 03): "; cin >> m; w->showSandT(m, y); cout << " Want to Move In Menue -> yes or no : "; cin >> menue; if (menue == "yes") goto again; else return 0; break;
case 2: cout << " Enter year(like 2020): "; cin >> y; w->showSandT(y); cout << " Want to Move In Menue -> yes or no : "; cin >> menue; if (menue == "yes") goto again; else return 0; break; case 3 cout << " Enter year(like 2020): " cin >> y; w->showSR(y); cout << " Want to Move In Menue -> yes or no : "; cin >> menue; if (menue == "yes") goto again; else return 0; break; case 4 { cout << " Enter year(like 2020): "; cin >> y; w->showSTSR(y); cout <<" Want to Move In Menue -> yes or no : "; cin >> menue; if (menue == "yes") goto again; else return 0; break; } case 5:{return 0;}
default:{ cout << "Invalid Input!"; cout << " Want to Move In Menue -> yes or no : "; cin >> menue; if (menue == "yes") goto again; else return 0;}}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started