How to input a string of charaters like "Peter Johnson"? My program only reads 1 single name, if I put a space, the program loops infinitely Writting John, works, but the space character makes it loop. Why is that? Also I know the program might not be completely finished.
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int x=0;
char name [25];
float paycheck;
cout<<"WELCOME TO THE EMPLOYEE SALARY GENERATION PROGRAM\n\n";
while (x!=-1)
{
cout<<"Enter employee name or -1 to stop the program\n";
cin>>name;
cout<<"Enter employee code (1=manager, 2=worker, 3=comission, 4=pieceworker) or -1 to stop the program\n";
cin>>x;
switch (x)
{
case 1:
cout<<"Your weekly total paycheck is 2 500 $\n"; // FIXED weekly manager's salary
break;
case 2: // 8.50 per hour + over time for workers
cout<<"Please enter the amount of hours worked\n";
cin>>paycheck;
if(paycheck<40)
paycheck=paycheck*8.50;
else
paycheck= (paycheck-40)*8.50 +(40*8.50);
cout<<name<<"'s paycheck is "<<paycheck<<"$\n";
break;
case 3: // comission workers make 250 + 5.7% of their weekly sales
cout<<"Please enter amount of weekly sale made\n";
cin>>paycheck;
paycheck = paycheck*5.7/100 + 250;
break;
case 4: // pieceworkers make 50$ per item produced
cout<<"Please enter the number of items produced this week\n";
cin>>paycheck;
paycheck = paycheck*50;
cout<<"The employee"<<name<<"Made"<<paycheck<<"$ this week";
break;
default:
break;
}
}
system ("PAUSE");
}