string name;
float hours, wage, netwage, SocsoContribution, HoursBalance;
cout<<"WELCOME TO XYZ";
cout<<"\n";
cout<<"Please enter your name: ";
cin>>name;
cout<<"Please enter your hours worked: ";
cin>>hours;
cout<<"\n";
cout<<"\n";
if(hours>60)
{
HoursBalance=hours;
wage += (40*5)+(20*8);
HoursBalance = hours - 60;
wage += HoursBalance*10;
}
else if(hours>40)
{
HoursBalance=hours;
wage += 40*5;
HoursBalance = hours - 40;
wage += HoursBalance*8;
}
else
{
wage = hours*5;
}
SocsoContribution = 0.01*wage;
netwage = wage - SocsoContribution;
cout<<"PAYSLIP";
cout<<"\nName: "<< name;
cout<<"\nHours worked: "<< hours<< " Hour(s)";
cout<<"\nWage: RM"<< wage;
cout<<"\nSocso Contribution: RM"<< SocsoContribution;
cout<<"\nNet Wage: RM"<< netwage;
So above is a C++ code I wrote for a wage calculating program. But whenever I run the code and I input the name with space lets say "Mr Adam", the code will skip the input for hours and then it just execute the rest of the code without having the value for hours. I'm using codeblocks IDE.