adspace


A company pays its salespeople on a commission basis. The
salespeople receive $200 per week plus 9 percent of their
gross sales for that week. For example, a saleperson who
sells $5000 worth of merchandise in a week receives $200
plus 9 percent of $5000, or a total of $650. You have been
supplied with a list of items sold by each salesperson. The
values of these items are as follows:
Item Value
A 239.99
B 129.75
C 99.95
D 350.89
Write a program that inputs one salesperson's items sold in
a week (how many of item A? of item B? etc.) and calculates
and displays that salesperson's earnings for that week.

Answer Posted / Shiv Prakash

Here's a C++ program that calculates the salesperson's earnings based on items sold:

```cpp
#include <iostream>
#include <map>

int main() {
std::map<std::string, double> itemValues;
itemValues["A"] = 239.99;
itemValues["B"] = 129.75;
itemValues["C"] = 99.95;
itemValues["D"] = 350.89;

int aCount = 0;
int bCount = 0;
int cCount = 0;
int dCount = 0;

std::cout << "Enter the number of items A sold: ";
std::cin >> aCount;
std::cout << "Enter the number of items B sold: ";
std::cin >> bCount;
std::cout << "Enter the number of items C sold: ";
std::cin >> cCount;
std::cout << "Enter the number of items D sold: ";
std::cin >> dCount;

double totalEarnings = (aCount * itemValues["A"]) + (bCount * itemValues["B"]) + (cCount * itemValues["C"]) + (dCount * itemValues["D"]);
std::cout << "Total earnings for this week: $" << totalEarnings << "n";

return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1169


Can union be self referenced?

1271


What is the latest version on c++?

1212


daily Routine of father

1488


What character terminates all character array strings a) b) . c) END

1402