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 / 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 |
What is the best c++ ide?
Should the member functions which are made public in the base class be hidden?
How do I exit turbo c++?
What are manipulators in c++ with example?
If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?
What is c++ and its features?
class Alpha { public: char data[10000]; Alpha(); ~Alpha(); }; class Beta { public: Beta() { n = 0; } void FillData(Alpha a); private: int n; }; How do you make the above sample code more efficient? a) If possible, make the constructor for Beta private to reduce the overhead of public constructors. b) Change the return type in FillData to int to negate the implicit return conversion from "int" to "void". c) Make the destructor for Alpha virtual. d) Make the constructor for Alpha virtual. e) Pass a const reference to Alpha in FillData
How a pointer differs from a reference?
Explain the pure virtual functions?
Explain the concept of copy constructor?
Implement strcmp
There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?