Stuck

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 19
Reputation: newbie2c++ is an unknown quantity at this point 
Solved Threads: 0
newbie2c++ newbie2c++ is offline Offline
Newbie Poster

Stuck

 
0
  #1
Nov 29th, 2006
Hi everyone, I have written a program and have encountered a few errors that I can't seem to fix(or don't know how to), any help would be great. Thanks in advance for the help! I'm very new to this so bare with me!:cheesy:

  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <iomanip>
  5. using namespace std;
  6. void get_wages(long[], int[], float[], float[], int);
  7. void display_wages(long[], float[], int);
  8.  
  9.  
  10. int main()
  11. {
  12. cout << "This program written for cs102 Online.\n";
  13. const int size = 7;
  14. long empId[size] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
  15. int hours[size];
  16. float pay_rate[size], wages[size];
  17.  
  18. get_wages(empId, hours, pay_rate, wages, size;
  19. display_wages(empId, wages, size);
  20. system("PAUSE");
  21. return 0;
  22. }
  23. void get_wages(long empId[], int hours[], float pay_rate[], float wages[], int size)
  24. {
  25. cout << "Employee ID number:" << endl;
  26. for (int count = 0; count < size; count++)
  27. {
  28. cout << "Employee ID number: ";
  29. cout << empId[count] << endl;
  30. cout << "Total number of hours worked: ";
  31. cin >> hours[count];
  32. while (hours[count] < 0)
  33. {
  34.  
  35. cout << "The hours worked cannot be negative, please enter a positive number. " << endl;
  36. cout << "Total number of hours worked: ";
  37. cin >> hours[count];
  38. }
  39. cout << "Employee's pay rate: ";
  40. cin >> pay_rate[count];
  41. while (pay_rate[count] < 6.0);
  42. {
  43. cout << "The employee's pay rate cannot be less than 6.00, please enter a higher pay rate. " << endl;
  44. cout << "Employee pay rate: ";
  45. cin >> pay_rate[count];
  46. }
  47.  
  48. wages[count] = pay_rate[count] * hours[count]; // formula for gross wages
  49. }
  50. }
  51. void display_wages (long empId[], float wages[], int size)
  52. cout << "\n\n";
  53. cout << "|||Employee ID Number|||Gross Wages|||" << endl;
  54. cout << "--------------------------------------" << endl;
  55. cout << fixed << showpoint << setprecision(2);
  56.  
  57. for (int count = 0; count < size; count++)
  58. {
  59.  
  60. cout << " " << empId[count] << " ";
  61. cout << "$ " << wages[count] << endl;
  62. }
  63. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Stuck

 
0
  #2
Nov 29th, 2006
Good news - there's only 2 syntax errors here!

You're missing a closing ')' here:
int main()
{
    cout << "This program written for cs102 Online.\n";
    const int size = 7;
    long empId[size] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
    int hours[size];
    float pay_rate[size], wages[size];
    
    get_wages(empId, hours, pay_rate, wages, size;

And here, you forgot to place an opening brace '{' to start the function:
void display_wages (long empId[], float wages[], int size) // missing {
        cout << "\n\n";
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC