CS 201p - Assignment 1

CS 201p - Assignment 1
CS 201p - Assignment 1


Solution:

#include <iostream>
using namespace std;

float calculateGross(float grossSales) {
    float commission = 0.09; // 9% commission
    float earnings = 700 + (commission * grossSales);
    return earnings;
}

int main() {
    // Salesperson data
    string salespersons[] = {"Sale Person 1", "Sale Person 2", "Sale Person 3"};
    float grossSales[] = {5000, 7000, 9000};
    
    float totalEarnings = 0;

    // Calculate earnings for each salesperson
    for (int i = 0; i < sizeof(grossSales) / sizeof(grossSales[0]); i++) {
        float earnings = calculateGross(grossSales[i]);
        cout << salespersons[i] << "'s earnings: " << earnings << " PKR" << endl;
        totalEarnings += earnings;
    }

    // Display total gross sales earnings
    cout << "Total gross sales earnings for the week: " << totalEarnings << " PKR" << endl;

    return 0;
}

Note:
Assignment should be submitted in .cpp format