Welcome to Dream.In.Code
Getting C++ Help is Easy!

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




Writing Payroll program

 
Reply to this topicStart new topic

Writing Payroll program, Calculating pay with monthly salary plus commission

leaj13
2 Oct, 2008 - 08:27 AM
Post #1

New D.I.C Head
*

Joined: 2 Oct, 2008
Posts: 3

Need assistance with writing a program that calculataes pay where the employee get a monthly salary plus commission. Any assistance would be appreciated.
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades
RE: Writing Payroll Program
2 Oct, 2008 - 08:58 AM
Post #2

Cantankerous Old Fart
Group Icon

Joined: 23 Aug, 2008
Posts: 597



Thanked: 60 times
Dream Kudos: 50
My Contributions
Show us what you've done so far.
User is offlineProfile CardPM
+Quote Post

leaj13
RE: Writing Payroll Program
3 Oct, 2008 - 11:28 AM
Post #3

New D.I.C Head
*

Joined: 2 Oct, 2008
Posts: 3

QUOTE(JackOfAllTrades @ 2 Oct, 2008 - 09:58 AM) *

Show us what you've done so far.



#include <iostream>
#include <cstring>
using namespace std;

int main()
{
//declare variables
char lastname [50];
char firstname [50];
double salary = 2500;
double salesamount0;
double commission0;

//get name
cout << "Enter last name: ";
cin.getline (lastname, 50 ) ;

cout << "Enter first name: ";
cin.getline (firstname, 50 ) ;

cout << "Enter salesamount: ";
cin>> salesamount;

//display name
cout<< "Your name is" << firstname<< " "<< lastname << salesamount <<endl;
}

if (salesamount <= 5000)
{
commission = salesamount * .08 + 2500;
}

else if (salesamount <= 10000)
{
commission = salesamount * .10 + 2500;
}
else
{
commission = salesamount * .12 + 2500;
}
system("pause");
return 0;
}


User is offlineProfile CardPM
+Quote Post

UG Cyber
RE: Writing Payroll Program
3 Oct, 2008 - 01:39 PM
Post #4

D.I.C Head
**

Joined: 24 Jul, 2008
Posts: 185



Thanked: 3 times
My Contributions
CODE

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
   //declare variables
   char lastname [50];
   char firstname [50];
   double salary = 2500;
   double salesamount0;
   double commission0;

   //get name
   cout << "Enter last name: ";
   cin.getline (lastname, 50 );
  
   cout << "Enter first name: ";
   cin.getline (firstname, 50 );

  cout << "Enter salesamount: ";
   cin>> salesamount;
    
   //display name
   cout<< "Your name is" << firstname<< " "<< lastname << salesamount <<endl;
}  
        
if (salesamount <= 5000)
{  
commission = salesamount * .08 + 2500;
}

else if (salesamount <= 10000)
{      
   commission = salesamount * .10 + 2500;
   }  
else
{
   commission = salesamount * .12 + 2500;
}
   system("pause");
   return 0;
}

[/quote]

use code blocks so it is easier to read and indent your code.

But you declared 'salesamount0' as a double but you are using 'salesamount'. Make sure you are using the same var.

when you display the name. try this
CODE

cout << "Your name is:  " << fistname << " " << lastname << endl;
cout << "Your sales amount is:  " << salesamount0 << endl;

//do calculations

cout << "Current commission is:  " << Commission << endl;
system("pause");


Hope this helped!! biggrin.gif

[edit] Same with the commision var. You declared it as a 'double commission0' and you used 'commission'

This post has been edited by UG Cyber: 3 Oct, 2008 - 02:24 PM
User is offlineProfile CardPM
+Quote Post

Sadaiy
RE: Writing Payroll Program
3 Oct, 2008 - 02:17 PM
Post #5

New D.I.C Head
*

Joined: 3 Oct, 2008
Posts: 38



Thanked: 1 times
My Contributions
Okay, what is the problem ? Most of your code looks okay aside from using different variables for the salesamount. Everything looks alright.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 04:21PM

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