CS201p Assignment 1 Solution [2023 Updated]

Assignment Problem Statement:

XYZ is a well-renowned company that pays its salespeople on a commission basis. The salespeople each receive 700 PKR per week plus 9% of their gross sales for that week.

For example, a salesperson who sells 4000 PKR worth of chemicals in a week receives 700 plus 9% of 4000 PKR or a total of 1060 PKR.

Develop a C++ program that uses a Repetitive Structure (while, for, do-while) to manipulate each salesperson’s gross sales for the week and calculate and display that salesperson’s earnings.

After calculating each salesperson’s earnings, the program should calculate the total gross sales earnings of all sales person’s for the week and display it on the screen.

To complete the required task, you need to declare the function name calculateGross(), which will take gross sales as an argument from the main function and return the gross earning of each person.

Gross sales will be calculated based on the data provided in the given table.

Sales PersonPercentage Gross SalesCommissionGross Sales
Sale Person 1                9 %            700             5000
Sale Person 2                9 %            700             7000
Sale Person 3                9 %            700             9000


We receive a lot of messages from students to make the assignment free.

So, now we are providing this assignment to you, please share this assignment as well as our website in order to support our website.

Hope you like it.

Here is a solution, we changed some variables’ names, etc. in order to prevent students who just download and submit the assignment.

So Piz make it unique. God bless you.

#include <iostream>
using namespace std;

// topicslearn.com
double calculateGross(double grossSales)
    double earn = (0.09 * grossSales) + 700;
    return earn;

int main()
    double sp1 = 5000;
    double sp2 = 7000;
    double sp3 = 9000;
    double earn, total;
    for (int i = 0; i < 3; i++)
        if (i == 0)
            earn = sp1;
        else if (i == 1)
            earn = sp2;
            earn = sp3;

        earn = calculateGross(earn);
        cout << "Sales Person " << i+1 << " gross earnings:" << earn<< endl;
        total += earn;

    cout << "Total gross sales earnings for the week:" << total;