Guten Abend,
ich habe heute mit c++ angefangen und mir auch schon ein V2B C++ video tutorial angesehen.
Danach wollte ich mir eine kleine Entgeltabrechnung schreiben, welches aber nicht ganz so funktioniert wie ich mir das vorstelle :/
und diese Fehler bekomme ich:
Habe google auch schon benutzt, allerdings helfen mir die glieferten Ergebnisse nicht, da ich C++ anfänger bin
ich habe heute mit c++ angefangen und mir auch schon ein V2B C++ video tutorial angesehen.
Danach wollte ich mir eine kleine Entgeltabrechnung schreiben, welches aber nicht ganz so funktioniert wie ich mir das vorstelle :/
Code:
#include <iostream>
#include <string>
using namespace std;
int main(){
int BBMG_KP = 3750;
int BBMG_RA = 5500;
int alter;
float kinder;
string familienstand;
string religion;
float lohnsteuer;
float bruttogehalt;
cout << "Wie alt sind Sie?\n";
cin >> alter;
cout << "Wieviele Kinder haben Sie?\n";
cin >> kinder;
cout << "Wie lautet ihr aktueller Familienstand?\n";
cin >> familienstand;
cout << "Welcher Religion gehören Sie an?\n";
cin >> religion;
cout << "Wie hoch ist ihr Bruttogehalt?\n";
cin >> bruttogehalt;
cout << "Wie hoch ist ihre Lohnsteuer?\n";
cin >> lohnsteuer;
float soli = lohnsteuer * 5.5 / 100;
cout << "Solidaritätszuschlag: " << soli << endl;
if(religion == "keine"){
int kist = 0;
}else{
float kist = lohnsteuer * 9 / 100;
}
if(bruttogehalt >= BBMG_KP){
float kv = BBMG_KP * 7.9 / 100;
float pv = BBMG_KP * 0.975 / 100;
}else{
float kv = bruttogehalt * 7.9 / 100;
float pv = bruttogehalt * 0.975 / 100;
}
if(bruttogehalt >= BBMG_RA){
float rv = BBMG_RA * 9.95 / 100;
float av = BBMG_RA * 1.4 / 100;
}else{
float rv = bruttogehalt * 9.95 / 100;
float av = bruttogehalt * 1.4 / 100;
}
cout << "Kirchensteuer: " << kist << endl;
cout << "Krankenversicherung: " << kv << endl;
cout << "Pflegeversicherung: " << pv << endl;
cout << "Rentenversicherung: " << rv << endl;
cout << "Arbeitslosenversicherung: " << av << endl;
cout << "=================================================" << endl;
float nettogehalt = bruttogehalt - ( lohnsteuer + soli + kist + kv + pv + rv + av);
cout << "Nettogehalt: " << nettogehalt;
return 0;
}
und diese Fehler bekomme ich:
Code:
1>------ Build started: Project: test, Configuration: Release Win32 ------
1>Compiling...
1>main.cpp
1>.\main.cpp(30) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(39) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(40) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(42) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(43) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(46) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(47) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(49) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(50) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
1>.\main.cpp(52) : error C2065: 'kist' : undeclared identifier
1>.\main.cpp(53) : error C2065: 'kv' : undeclared identifier
1>.\main.cpp(54) : error C2065: 'pv' : undeclared identifier
1>.\main.cpp(55) : error C2065: 'rv' : undeclared identifier
1>.\main.cpp(56) : error C2065: 'av' : undeclared identifier
1>.\main.cpp(58) : error C2065: 'kist' : undeclared identifier
1>.\main.cpp(58) : error C2065: 'kv' : undeclared identifier
1>.\main.cpp(58) : error C2065: 'pv' : undeclared identifier
1>.\main.cpp(58) : error C2065: 'rv' : undeclared identifier
1>.\main.cpp(58) : error C2065: 'av' : undeclared identifier
Habe google auch schon benutzt, allerdings helfen mir die glieferten Ergebnisse nicht, da ich C++ anfänger bin