How Do I Declare Variable?

I'm trying to write a program that reads information and prints a payroll statement, however when I give it the name on the first cout it only gives me R instead of Roel (my name) at the end where it says cout << "Employee Name: " << n. Could someone please guide me to fix this? Thank You!


#include <iostream>
using namespace std;

int main()
{
char n ;
double h ;
double r ;
double f ;
double s ;

cout << "Enter enployee's name: " << endl;
cin >> n ;

cout << "Enter number of hours worked in a week: " << endl;
cin >> h ;

cout << "Enter nhourly pay rate: " << endl;
cin >> r ;

cout << "Enter federal tax witholding rate: " << endl;
cin >> f ;

cout << "Enter state tax witholding rate: " << endl;
cin >> s ;

cout << "Employee Name: " << n << endl << "Hours Worked: " << h <<
endl << "Pay Rate: " << r;

getchar();

return 0;
}
Use std::string n instead of char n. Char can only store one letter.
Unbelievable it worked! Thanks Dark Goomba
Topic archived. No new replies allowed.