Files
Cpp-Cookbook/ArbeitStundenRechner/main.cpp

32 lines
947 B
C++

#include <iostream>
using namespace std;
int main() {
const string weekdays[5] = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag"};
float workHours[5];
float totalHours = 0;
for (int i = 0; i < size(weekdays); i++) {
cout << "Wie viel hast du am " << weekdays[i] << " gearbeitet?" << endl;
cin >> workHours[i];
}
for (const float workHour: workHours) {
totalHours = totalHours + workHour;
}
cout << endl << "Insgesamt sind das " << totalHours << " Stunden." << endl;
if (totalHours < 40) {
float missingHours = 0;
missingHours = 40 - totalHours;
cout << "Du hast nicht genug gearbeitet. du hast " << missingHours << " Stunden zu wenig gearbeitet.";
} else {
float overtime = 0;
overtime = totalHours - 40;
cout << "Du hast genug gearbeitet. du hast ganze " << overtime << " Ueberstunden" << endl;
}
return 0;
}