Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,262 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,507 people online right now. Registration is fast and FREE... Join Now!




Wage calculation

 
Reply to this topicStart new topic

Wage calculation, i have to write a program and i dont know where to start

jazzariah
10 Dec, 2006 - 12:07 PM
Post #1

New D.I.C Head
*

Joined: 8 Nov, 2006
Posts: 10


My Contributions
ok im homework assign is as follow:

write a program using structures that will compute the weekly, monthly and yearly wage of two employees. with the data coming from the user.

theres more but i understand how to do than. what im having trouble with in the user input and setting up the structure.
im thinking that the weekly, monthly and yearly wage goes in the structure. but i dont understand how all that works with the user in put. confused!

User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Wage Calculation
10 Dec, 2006 - 12:11 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,013



Thanked: 18 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
you must provide 'good faith' code, before anyone will help you.
User is offlineProfile CardPM
+Quote Post

jazzariah
RE: Wage Calculation
11 Dec, 2006 - 08:29 AM
Post #3

New D.I.C Head
*

Joined: 8 Nov, 2006
Posts: 10


My Contributions
QUOTE(William_Wilson @ 10 Dec, 2006 - 01:11 PM) *

you must provide 'good faith' code, before anyone will help you.


i wasnt tryin to get the code written for me. i just dont understand what the user in put would be.

the second part is conditional states : if the emp. makes 50k give them a 7% raise, if they make 100k take a away5% and print out the new total. i understand that.

i havent tried it yet but here is how i think it might go.

CODE


#include <iostream.h>


struct Employee;

{
   float WeeklyWage;
   float MonthlyWage;
   Float yearlyWage;

};


int main ()


/*****ok this is where im having the problem im not sure if the above is right cuz i dont really understand struct. i dont understand what the user input is. cuz theres only to emp. so is the user the names ?? confused.*/

This post has been edited by Dark_Nexus: 11 Dec, 2006 - 10:51 AM
User is offlineProfile CardPM
+Quote Post

may4life
RE: Wage Calculation
13 Dec, 2006 - 05:55 AM
Post #4

New D.I.C Head
*

Joined: 5 Nov, 2006
Posts: 23


My Contributions
Here's how to start the program, read it and study hard. I've left out the raises and totals for you to figure out. I would just like to point out that this is NOT the only way to do this. There are LOADS of ways to write this program (even I could have done it in several ways, this is just the final version of the first attempt). Good luck!
CODE

#include <iostream>

using namespace std;

// you have to understand that the employee struct is created only once. Each instance of this
// struct is now an employee of a company with these three variables in his possession
struct Employee
{
    float weekly;
    float monthly;
    float yearly;
};

int main()
{
    Employee emp1; // emp1 is employee number 1. He has his own weekly, monthly and yearly wage
    Employee emp2; // emp2 is another employee, having also his own weekly, monthly and yearly wage.
                   // You must understand that emp1 and emp2 have the same variables in their
                   // possession: weekly, monthly and yearly wage, which are unique to each employee

    int weeklyWage=0;
    int monthlyWage=0;
    int yearlyWage=0;

    for (int i=1; i<=2; i++) // enter values from user
    {
        cout << "Enter weekly wage for Employee "  << i << ": ";
        cin >> weeklyWage;
        cout << "Enter monthly wage for Employee " << i << ": ";
        cin >> monthlyWage;
        cout << "Enter yearly wage for Employee "  << i << ": ";
        cin >> yearlyWage;

        switch (i) // this just makes the program more flexible and reusable
        {
            case 1:
                {
                    emp1.weekly  = weeklyWage;
                    emp1.monthly = monthlyWage;
                    emp1.yearly  = yearlyWage;
                } break;
            case 2:
                {
                    emp2.weekly  = weeklyWage;
                    emp2.monthly = monthlyWage;
                    emp2.yearly  = yearlyWage;
                } break;
        }
    }

    cout << endl;

    // display the values for debugging purposes
    cout << "Employee 1 weekly wage: "  << emp1.weekly  << endl;
    cout << "Employee 1 monthly wage: " << emp1.monthly << endl;
    cout << "Employee 1 yearly wage: "  << emp1.yearly  << endl;

    cout << "Employee 2 weekly wage: "  << emp2.weekly  << endl;
    cout << "Employee 2 monthly wage: " << emp2.monthly << endl;
    cout << "Employee 2 yearly wage: "  << emp2.yearly  << endl;
    return 0;
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:11PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month