RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 619 | Replies: 4 | Solved | Thread Tools  Display Modes
Reply
Join Date: Jan 2008
Posts: 7
Reputation: yarita is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yarita's Avatar
yarita yarita is offline Offline
Newbie Poster

Help plz can someone help me?? code for employee's hours worked

  #1  
Jan 11th, 2008
I am just beginning in a C++ class and I am having a hard time setting up the code for using a modulus operator. The problem assigned has user input as name and hours worked. The program is to output the name, weeks worked, days worked, and hours worked based on the hours worked input. I keep getting errors on my code on the last part, which is the output. Can someone help me out on this? I'm very confused right now!


my code:



  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6.  
  7. // declares constants and variables
  8.  
  9. string name ; //name is a variable of type string
  10. const int hoursweek = 40;
  11. const int hoursday = 8;
  12. int hours = 0;
  13. int weeks_worked = 0;
  14. int days_worked = 0;
  15. int hrs_worked = 0;
  16. int hours % hoursweek = 0;
  17.  
  18.  
  19. //enter input items
  20. cout <<"Enter employee's name: \n\n";
  21. getline (cin,name);
  22.  
  23. cout <<"\n\n";
  24.  
  25. cout <<"Enter number of hours worked: \n\n";
  26. cin >>hours ;
  27. cout <<"\n\n" ;
  28.  
  29. //calculate weeks, days, and hours worked
  30. weeks_worked = hours % hoursweek ;
  31. days_worked = hours % hoursweek ;
  32. hrs_worked = hours % hoursweek ;
  33.  
  34.  
  35. //enter output items
  36. cout <<"Employee's name: "<<name:<< worked <<hours % hoursweek<< " \n\n" ;
  37.  
  38.  
  39. system ("pause") ;
  40. return 0;
  41. }
Last edited by Ancient Dragon : Jan 11th, 2008 at 10:40 pm. Reason: add code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,870
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 1014
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: plz can someone help me?? code for employee's hours worked

  #2  
Jan 11th, 2008
you forgot to include <string>

>> system ("pause") ;
Don't do that. Just use cin.get()
<<Hire Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Join Date: Sep 2007
Location: Ukraine, Kyiv
Posts: 114
Reputation: zhelih has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 11
zhelih's Avatar
zhelih zhelih is offline Offline
Junior Poster

Re: plz can someone help me?? code for employee's hours worked

  #3  
Jan 12th, 2008
  1. cout <<"Employee's name: "<<name:<< worked <<hours % hoursweek<< " \n\n" ;
Why do you put two points after name?

  1. cout <<"Employee's name: "<<name<<"Worked: "<< worked <<"Hours: "<<hours % hoursweek<< " \n\n" ;
Last edited by zhelih : Jan 12th, 2008 at 12:44 pm.
An Apple a Day keeps a Doctor away!
Reply With Quote  
Join Date: Nov 2007
Posts: 52
Reputation: manzoor is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
manzoor manzoor is offline Offline
Junior Poster in Training

Re: plz can someone help me?? code for employee's hours worked

  #4  
Jan 12th, 2008
you cannot declare an int with spaces

int hours % hoursweek;

the identifier is illegal in c++ it shouldn't contain spaces
Reply With Quote  
Join Date: Jan 2008
Location: Bhutan
Posts: 12
Reputation: Arpy Giri is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
Arpy Giri's Avatar
Arpy Giri Arpy Giri is offline Offline
Newbie Poster

Re: plz can someone help me?? code for employee's hours worked

  #5  
Jan 13th, 2008
sending the code,which i suppose u were working upon
Attached Files
File Type: cpp yarita.cpp (1.2 KB, 7 views)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the C++ Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:13 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC