inital commit, adding all school projects
This commit is contained in:
50
MonatlicheUmsaetze/main.cpp
Normal file
50
MonatlicheUmsaetze/main.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::string formatMoneyGerman(double amount) {
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::setprecision(2) << amount;
|
||||
std::string s = oss.str();
|
||||
|
||||
// Replace decimal point with comma
|
||||
size_t dotPos = s.find('.');
|
||||
if (dotPos != std::string::npos)
|
||||
s[dotPos] = ',';
|
||||
|
||||
// Insert thousands separator (dot) every three digits before comma
|
||||
int insertPos = static_cast<int>(dotPos) - 3;
|
||||
while (insertPos > 0) {
|
||||
s.insert(insertPos, ".");
|
||||
insertPos -= 3;
|
||||
}
|
||||
|
||||
return s + " €";
|
||||
}
|
||||
|
||||
int main() {
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
cout << fixed << setprecision(2);
|
||||
|
||||
double Umsatz[12], summe = 0;
|
||||
|
||||
cout << "Monatliche Umsätze:";
|
||||
cout << endl << "--------------------";
|
||||
|
||||
cout << endl << endl << "Bitte geben Sie die Umsätze der letzten Monate ein!" << endl;
|
||||
|
||||
for (int i = 0; i < 12; i++ ) {
|
||||
cout << endl << "Umsatz für Monat [" << i + 1 << "]: ";
|
||||
cin >> Umsatz[i];
|
||||
summe += Umsatz[i];
|
||||
}
|
||||
cout << endl << "Die Summe aller monatlichen Umsätze beträgt: " << formatMoneyGerman(summe) << endl;
|
||||
cout << "Der durchschnittliche monatliche Umsatz beträgt: " << formatMoneyGerman(summe / 12) << endl;
|
||||
cout << endl;
|
||||
cout << "Für welchen Monat soll der Umsatz angezeigt werden?" << endl;
|
||||
cout << "Bitte geben Sie eine Zahl zwischen 1 und 12 an:";
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user