Question
Write a Java program, including comments, to do the following: Outline: The program will compute statistics for how salespeople did. The program will read in
Write a Java program, including comments, to do the following:
Outline:
The program will compute statistics for how salespeople did. The program will read in the id number of a salesperson, the number of customers who bought the product, the number of customers who did not buy, and the quota (this is the number of customers who must buy from this salesperson). The program will compute various things about the salesperson, and it will print all of this out. Then it will repeat the process for a new salesperson, over and over again, until the entire set of data has been taken care of.
Here are the details:
1. The program will read in the id number of a salesperson (see step 6 below). The program will read in (and print) the number of customers who bought the product, the number who did not buy, and the quota. For example, the program could read in the following:
1234 20 5 30 [idno 1234, 20 bought 5 didn't quota is 30]
2. The program will compute and print the total number of customers (the number who bought plus the number who didn't). It will also compute how many more the salesperson needs to get to the quota (maybe 0), or how many the salesperson is above the quota.
Neatly print all this information. If the salesperson reached or is over the quota, print a message of congratulations. Otherwise, print a message saying the salesperson must try harder.
3. The program will compute the salesperson's sales percentage, which is a decimal value between 0 and 1. The sales percentage is defined to be the number of customers who bought divided by the total number of customers. (You can assume the salesperson always has at least one customer--see optional 2.)
For the data values shown for idno 1234 above, the total is 25 and the sales percentage is 20 / 25 = 0.800.
Print this value as shown, with exactly 3 decimal places.
4. The program should also assign the salesperson a bonus. The bonus is the number of customers who bought times 2, minus the number of customers who did not buy. For example, idno 1234 got a bonus of 35 (20 bought x 2 - 5 who didn't buy). However, the bonus cannot be negative. For example, if 5 bought and 20 didn't, the bonus would be 0. (Be sure to test this in your program.)
The program should print the bonus assigned to the salesperson.
5. The program should determine if the salesperson had more customers who bought than did not, the same number of each, or more who did not buy. It should print an appropriate message in each of these three cases.
6. Then the program should skip a few lines of output and repeat the entire series of steps for the next salesperson, and so on, until the last salesperson has been processed. (You must decide how to recognize that the last salesperson has been processed. Explain in a comment)
7. At that point, print the total number of salespersons (you must keep track of this as the program executes), then stop.
DATA: Be sure to read in data for at least 12 salespersons. Include a salesperson with no one who bought and a salesperson with everyone who bought (but still below the quota). Have some salespersons who don't make the quota, some who do exactly, and some who are over the quota. Have some with a positive bonus and some with a 0 bonus. (Have at least two of each type described.) Be sure to make up a good set of data covering all cases.
Here is a complete set of output for two typical salespersons:
(Use these 2 plus at least 12 more)
id 1234 id 7890
10 bought 15 didn't 21 bought 14 didn't
quota 22 quota 21
total customers 25 total customers 35
12 below quota try harder made quota congratulations
bonus is 15 bonus is 28
more didn't buy more bought than didnt
sales pct. is 0.400 sales pct. is 0.600
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started