#include using namespace std; int main() { const int lowestDayInMonth = 1; const int highestDayInMonth = 31; const int lowestTemperature = -70; const int highestTemperature = 70; const int lowestMmRain = 0; const int highestMmRain = 200; cout << "Velkommen til vaerprogrammet mitt!"; int run = 1; while(run == 1) { int daysInMonth = 0; float minTemp = 0, maxTemp = 0, mmRain = 0; float sumMinTemp = 0, sumMaxTemp = 0, sumMmRain = 0; char appStatus; cout << "\n\nVennligst tast inn antall dager i maaneden: (" << lowestDayInMonth << " -> " << highestDayInMonth << ")\n"; do { cin >> daysInMonth; cin.ignore(); if(daysInMonth < lowestDayInMonth || daysInMonth > highestDayInMonth) cout << "Du maa skrive inn et tall mellom " << lowestDayInMonth << " og " << highestDayInMonth << "\n"; } while(daysInMonth < lowestDayInMonth || daysInMonth > highestDayInMonth); for(int i = 1; i <= daysInMonth; i++) { cout << "\nDag nummer: " << i << "\n"; cout << "\tMin. temp: (" << lowestTemperature << " -> " << highestTemperature << ")\n"; do { cin >> minTemp; cin.ignore(); if(minTemp < lowestTemperature || minTemp > highestTemperature) cout << "Du maa skrive inn et tall mellom " << lowestTemperature << " og " << highestTemperature << "\n"; } while(minTemp < lowestTemperature || daysInMonth > highestTemperature); sumMinTemp += minTemp; cout << "\tMax. temp: (" << minTemp << " -> " << highestTemperature << ")\n"; do { cin >> maxTemp; cin.ignore(); if(maxTemp < minTemp || minTemp > highestTemperature) cout << "Du maa skrive inn et tall mellom " << minTemp << " og " << highestTemperature << "\n"; } while(maxTemp < minTemp || maxTemp > highestTemperature); sumMaxTemp += maxTemp; cout << "\tMm. rain: (" << lowestMmRain << " -> " << highestMmRain << ")\n"; do { cin >> mmRain; cin.ignore(); if(mmRain < lowestMmRain || minTemp > highestMmRain) cout << "Du maa skrive inn et tall mellom " << lowestMmRain << " og " << highestMmRain << "\n"; } while(mmRain < lowestMmRain || mmRain > highestMmRain); sumMmRain += mmRain; } cout << "\n"; cout << "Gjennomsnittlig min. temp: " << sumMinTemp/daysInMonth << "\n"; cout << "Gjennomsnittlig max. temp: " << sumMaxTemp/daysInMonth << "\n"; cout << "Gjennomsnittlig nedbor: " << sumMmRain/daysInMonth << "mm\n"; cout << "Total nedbor: " << sumMmRain << "mm\n"; cout << "\nVil du legge inn enda en maaned? (j/n)\n"; cin >> appStatus; if(appStatus == 'n') { cout << "Takk for at du brukte meg!"; run = 0; } cin.get(); } }