I am stuck. This is what I have so far.
#include<iostream>
using namespace std;
double pay(double rate,double hours);
int main()
{
cout <<"The pay for 30 hours at $8.50 is $" <<pay (8.50,30)<<endl;
cout <<"The pay for 40 hours at $12.00 is $" <<Pay(12.00, 40)<<endl;
cout <<"The pay for 50 hours at $10.00 is $" <<Pay(10.00, 50) <<endl;
return 0;
}
double pay(double rate,double hours)
//you can declare local variables here that you might use
cout << "The total amount for hours work at 30 is $ " << endl;
cout << 'The total amount for hours work at 40 is $ " << endl;
cout << ""The total amount for hours work at 50 is $ " << endl;
}
This is what I have so far I try to build and I am getting several errors. Can you assist me in this program. This program is testing the overtime function using a driver and a parameter.
To ohsnap 1319 and MaikCae Thanks for your help. Yes I got it to work. Still learning. This is my first semester in learning how all of this programming works. Again Thanks
I am having some trouble with this program. It is to read in a single line of characters using cin.getline. have the program use a pointer to count the number of characters and the number of digits. The user types in My name is R2D2 the program should respond with 15 characters were typed 2 were digits. The problem I am getting is 15 characters typed and 15 digits typed. Here is my program:
int main()
{
char line [81];
char* ch_ptr = line;
int count = 0;
int digit = 0;
cout << "Enter a line of characters: " << endl << endl;
cout << "Enter a line of digits: " << endl << endl;
cin.getline(line, 81);
while ( *ch_ptr !='\0')
{
++ch_ptr;
++count;
}
cout << endl;
cout << "The key you entered has " << count << " characters. " << endl;
cout << "The key you entered has " << count << " digits. " << endl;
return 0;
}
This is what I have. Any suggestion to how I can get it to type how many digits.
There has to be a function in the cctype header to calculate that length... It also doesn't help that you are outputting the number of digits with the exact same variable as the number of characters.
Include <cstring> and call the strlen function. Then just loop through your char array and check each char for the isdigit using the cctype library.