Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 68 additions & 76 deletions Lab_21/city_temperature_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,81 +608,73 @@ void CityHumidityInfo() {
}

int main() {
for (int i = 0; i < 1000; i++) {
system("cls");

cout << "Main Menu: \n";
cout << "1. City temperature information\n";
cout << "2. City rainfall information\n";
cout << "3. City humadity information\n";
cout << "4. Dispalaying all\n";

cout << "Your choice: \n";

switch (_getch())
{

case '1': {
system("cls");
CityTemperatureInfo();
system("pause");
}break;

case '2': {
system("cls");
CityRainFallInfo();
system("pause");
}break;

case '3': {
system("cls");
CityHumidityInfo();
system("pause");
}break;

case '4':{
system("cls");
cout << "DISPLAYING ALL\n";
/*CityTemperature Temperature1; // creating an object
CityRainFall R1;
CityHumidity Humidity1;

cout << "TEMPERATURE:\n";
ifstream inP("Temperature", ios::binary);
while (inP.read((char*)&Temperature1, sizeof(CityTemperature))) {
Temperature1.getClimateData();
}
inP.close(); // closing the files after execution

cout << "RAINFALL:\n";
ifstream inP1("R", ios::binary);
while (inP1.read((char*)&R1, sizeof(CityRainFall))) {
R1.getClimateData();
}
inP1.close(); // closing the files after execution

cout << "HUMIDITY:\n";
ifstream inP2("R", ios::binary);
while (inP2.read((char*)&Humidity1, sizeof(CityRainFall))) {
Humidity1.getClimateData();
}
inP2.close(); // closing the files after execution*/


system("pause");

}
break;

default: {
cout << "Your choice is not available in menu!\n";
system("pause");
}
break;
} // switch

} // for loop


for (int i = 0; i < 1000; i++) {
// Clear the console using a safer method
#ifdef _WIN32
std::system("cls"); // Consider replacing with platform-specific API calls
#else
std::system("clear");
#endif

std::cout << "Main Menu: \n";
std::cout << "1. City temperature information\n";
std::cout << "2. City rainfall information\n";
std::cout << "3. City humidity information\n";
std::cout << "4. Displaying all\n";

std::cout << "Your choice: \n";

switch (_getch()) {
case '1': {
#ifdef _WIN32
std::system("cls");
#else
std::system("clear");
#endif
CityTemperatureInfo();
std::cout << "Press any key to continue...";
_getch();
} break;

case '2': {
#ifdef _WIN32
std::system("cls");
#else
std::system("clear");
#endif
CityRainFallInfo();
std::cout << "Press any key to continue...";
_getch();
} break;

case '3': {
#ifdef _WIN32
std::system("cls");
#else
std::system("clear");
#endif
CityHumidityInfo();
std::cout << "Press any key to continue...";
_getch();
} break;

case '4': {
#ifdef _WIN32
std::system("cls");
#else
std::system("clear");
#endif
std::cout << "DISPLAYING ALL\n";
std::cout << "Press any key to continue...";
_getch();
} break;

default: {
std::cout << "Your choice is not available in menu!\n";
std::cout << "Press any key to continue...";
_getch();
} break;
} // switch
} // for loop
}