×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Help with my code

Help with my code

Help with my code

(OP)
Can someone take a look at my code. I'm having some errors and do not know how to correct. Not looking for someone to give me the answer, but walk me though to better understand.
This is a compiler to compute wages.

CODE

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[ ])
{

int a = 40;                    //No. of hrs worked during week
float b = 12.75;               //Pay rate: dollars per hour
float c = 510;
cout << a * b;
cout << c;

//Weekly wages

// read in the hours worked

cout << endl;
cout << "Number of hours worked during the week (integer) = ";
cin >> hours_worked;

// read in the pay rate

cout << "Hourly pay rate (specify two digits after the decimal point) = ";
cin >> pay_rate;

// compute wages

sum = (number of hours * pay rate);

// display the result

cout << endl;
cout << "The weekly wages are: $" << wages << endl;

return (0); // terminate with success

}

RE: Help with my code

It would help if you also posted the errors you're getting.
From what I can see though, you haven't declared these variables anywhere:
hours_worked, pay_rate, sum, wages

and then you have (number of hours * pay rate) which makes absolutely no sense whatsoever.

RE: Help with my code

(OP)
Have I no errors now. But is this on the right track now?

CODE

[#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[ ])
{

//cout << "hours worked: ";       //No. of hrs worked during week
//cin >> 40;
//cout << " pay rate: $"; per hour    //Pay rate: dollars
//cin >> 12.75;
//cout << "weekly wages: ";             //Weekly wages
//cin >> 510;

// read in the hours worked

cout << endl;
cout << "Number of hours worked during the week (integer) = ";
//cin >> hours_worked;

// read in the pay rate

cout << "Hourly pay rate (specify two digits after the decimal point) = ";
//cin >> pay_rate;

// compute wages

//weekly_wages = computewages (hours,rate,sum );

// display the result

cout << endl;
//cout << "The weekly wages are: $" << wages << endl;

return (0); // terminate with success

}]

RE: Help with my code

Well commenting out the lines that give you errors will get it to compile, but I doubt it does what you want.
It would be better to fix the errors rather than just commenting them out.  i.e. declare the variables before you start using them.

Also, you should put [code] [/code] tags around your code.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close