i have written simple code to calculate payroll, runs ok when i put right kind of input( related to what its asking for) but when i put any other input then it ignores all the other codes and gives random number as calculation and goes to end of the program. for eg. if i input alphabet instead of number in rate per hour or in hour worked....please help!!!
#include <iostream>
#include <string>
using namespace std;
double calPayroll(double rate, double hour);
int main()
{
    char option;
    string name;
    double rate,hour;
    cout << "Please enter employee full name: ";
    getline(cin,name);
    cout << "Please enter "<<name <<"  rate per hour: ";
    cin >> rate;
    cout << "Please enter total hour " <<name << " worked: ";
    cin >> hour;
    cout <<"\n\nSalary for " << name << " is: " << calPayroll(rate,hour)      <<endl <<endl;
    cout << "Next Payroll: Press any key to continue or 'n' to exit)\n\n";
    cin >> option;
    cout<< option;
system ("pause");
return 0;
}
 
     
     
    