473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

functions

6
hey guys this is what i have to do, I already got the first part, but I kind of nieed help to make it in three speprate functions, the follwoinf is what i have to do and then what I have already coded. I have coded just for one person, but I need more. if any1 can help, would be appreciated


This is my school assignment, pls if any1 can help, would be appreciated


The Rinky Dooflingy Company has a product line that includes five items. These
items sell for $100 (item number 1), $75 (item number 2), $120 (item number 3),
$150 (item number 4), and $35 (item number 5). There are four salespersons
working for this company, and the following table gives the sales report for a
typical week:
Salesperson Item
Number 1 2 3 4 5
1 10 4 5 6 7
2 7 0 12 1 3

3 4 9 5 0 8
4 3 2 1 5 6


Write a program to:
(a) Input the number of each item sold by a salesperson and compute his/her
total dollar sales using the data input. The numbers above are only for illustration.
(b) Compute the total income for each salesperson for the week. Income consists
of a total sales commission of 10% for each salesperson along with a fixed salary
of $200 per week.
(c) Display the sales data, total dollar sales, commission amount and total income
for each salesperson in a pleasing and appropriate format. All dollar amounts
should display with 2 decimal points and DO NOT rip off the salesman by only
using whole dollar amounts.

Write separate functions to perform items a, b, and c with parameter passing and
calls from the driver module. Do not use global variables. If you are familiar with
arrays you may use them if you want.

#include <iostream>
#include <iomanip>
using namespace std;
int salesperson1(int item1, int item2, int item3, int item4, int item5)
{

int item, total;
cout<<"How many times was item 1 sold by salesperson1: ";
cin>>item1;
cout<<"How many times was item 2 sold by salesperson1: ";
cin>>item2;
cout<<"How many times was item 3 sold by salesperson1: ";
cin>>item3;
cout<<"How many times was item 4 sold by salesperson1: ";
cin>>item4;
cout<<"How many times was item 5 sold by salesperson1: ";
cin>>item5;
cout<<"\n";
total=(item1*100)+(item2*75)+(item3*120)+(item4*15 0)+(item5*35);
return total;
}

int main()
{
float subtotal, moneyearned;

subtotal=salesperson1(100,75,120,150,35);
moneyearned=(subtotal/100)+200;
cout<<setprecision(2)<<showpoint<<fixed<<endl;
cout<<"Salesperson one, sold: $ "<<subtotal<<" on all 5 items"<<endl;
cout<<"Salesperson one made total of: $"<<moneyearned<<" per week\n";
system ("pause");
return 0;
}
Feb 8 '07 #1
2 1117
Ganon11
3,652 Expert 2GB
(b) Compute the total income for each salesperson for the week. Income consists of a total sales commission of 10% for each salesperson along with a fixed salary of $200 per week.
You have to write a function for this. Think about:

1) What should it return?
2) What parameters will it need?
3) Exactly what calculation needs to be done?

Combine these three and you'll have your function.
Feb 8 '07 #2
une
6
thanks for the help,
please if you could just give some hints, with a code of part b)
Feb 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
21
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
14
by: v4vijayakumar | last post by:
Why we need "virtual private member functions"? Why it is not an (compile time) error?
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.