Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:06:53+00:00 2026-05-26T13:06:53+00:00

Hello everyone I am learning functions so I took a old practice program and

  • 0

Hello everyone I am learning functions so I took a old practice program and modified it to use functions. My problem is however when it comes time to display the commission I am calculating I am getting the wrong values. Any help would be appreciated. I have everything working except the commission prices.

Code

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

int ID;
double salary, pcs, printer, accessory, maint;
double pcbase = 8000.00, printerbase = 1500.00, accbase = 1000.00, maintbase = 500.00;
double pccomm = .15, printercomm = .10,acccomm = .05, maintcomm = .08;

double calcComm(double sales, double base, double percent);
void display(double, double, double, double);


int main()
{
    cout<<"Enter Salesman ID\n";
    cin>>ID;
    while (ID != -999)
    {
        cout<<"Enter base salary\n";
        cin>>salary;
        cout<<"Enter PC sales\n";
        cin>>pcs;
        pccomm = calcComm(pcs, pcbase, pccomm);

        cout<<"Enter Printer Sales\n";
        cin>>printer;
        printercomm = calcComm(printer, printerbase, printercomm);

        cout<<"Enter Accessory Sales\n";
        cin>>accessory;
        acccomm = (accessory, accbase, acccomm);

        cout<<"Enter Maintenance Sales\n";
        cin>>maint;
        maintcomm = (maint, maintbase, maintcomm);

        display(pccomm, printercomm, acccomm, maintcomm);
        cout<<"\n\nEnter Salesman ID or -999 to quit\n";
        cin>>ID;
    }

    system ("PAUSE");
    return 0;
}

double calcComm(double sales, double base, double percent)
{
    double commission;
    if (sales < base)
        commission = 0;
    else 
        commission = sales * percent;
    return commission;
}

void display(double pccomm, double printercomm, double acccomm, double maintcomm)
{
    cout<<"Salesman ID:"<<ID;
    cout<<"\nProduct"<<"            Sales Amount"<<"      Commission\n";
    cout<<"Personal Computers"<<"     "<<pcs<<"               "<<pccomm;
    cout<<"\nPrinters"<<"               "<<printer<<"               "<<printercomm;
    cout<<"\nAccessories"<<"            "<<accessory<<"               "<<acccomm;
    cout<<"\nMaintenance"<<"            "<<maint<<"               "<<maintcomm;

    double total = 0,totaldue = 0;
    total = pccomm+printercomm+acccomm+maintcomm;
    totaldue = total+salary;
    cout<<"\n\n\nTotal Commission                               "<<total;
    cout<<"\n       Base Pay                                "<<salary;
    cout<<"\n      Total Due                                "<<totaldue;
}

My Desired Output is

Salesman ID: 111
Product                   Sales             Commission
Personal Computer         5000.00                0.00
Printers                  2000.00               50.00
Accessories                600.00                0.00
Mainteance                1000.00               40.00

Total Commission                                90.00
Base Pay                                      1234.56
Total Due                                     1324.56
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:06:53+00:00Added an answer on May 26, 2026 at 1:06 pm

    You have:

    acccomm = (accessory, accbase, acccomm);
    

    I assume this needs to be acccomm = calcComm(accessory, accbase, acccomm);.

    Same for calculation of maintcomm. The way you wrote the code, it will use the comma operator, which just evaluates to the last operand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everyone I'm currently implementing a simple programming language for learning experience but I'm
Hello everyone and as usual, thank you to anyone taking the time to read
Hello everyone I am just learning my first programming language and have just corrected
Hello everyone I use MongoDB find() method like this: $cursor = $collection->find(); foreach($cursor as
Hello Everyone I am new being in ANDROID so I am getting one problem
Hello everyone I've never had a problem which i cant solve with google... So
Hello everyone and thank you very much for your time. Basically what I am
Hello everyone I am completely stuck with this problem. I want add the name
Hello everyone I try to solve asterisk tree problem and found my code is
Hello everyone and thank you for your time. I would just like to say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.