Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Programming Project Two: Sales Report

Creating the solution to a Programming Project is not an exercise in finding an answer on the Internet and
submitting it as your own work. Submitting someone else’s work as your own is plagiarism. Plagiarism is an
example of Scholastic Dishonesty. Copying all or part of a solution from a site like Chegg is plagiarism.
Your assignment is to create a Java program that keeps track of sales activity using a two-dimensional array.
Your array will have three (3) rows, one for each of three salespeople. The array will have four (4) columns, one
for each of the four different products being sold. Your program will accept input from the keyboard and produce
record counts and a report that are displayed on the screen.
This assignment is your opportunity to show us what you know about creating a two-dimensional array,
accumulating values within the array, and using the contents of the array to produce a report.
Input will come in the form of your user entering three integers separated from each other by one or more
blanks on a single line. The three values represent:
 Salesperson [1, 2, or 3]
 Product [1, 2, 3, or 4]
 Quantity, a positive integer
Your program will keep track of the total number of entries (lines of input) made by the user.
Your program will skip over and keep track of the number of lines of input that are not valid. An entry is
considered not valid if any of the following conditions exist:
 The value for the salesperson is out of the range from 1 through 3, inclusive.
 The value for the product is out of the range from 1 through 4, inclusive.
 The quantity value is less than or equal to zero (0).
If any of these values are invalid, increment the count of records skipped, display an appropriate warning
message, and continue to prompt the user to make additional entries.
For a sales transaction where salesperson 2 sold 50 units of product 3, the user would enter 2 3 50. It is
possible for a salesperson to have multiple transactions involving the same product. The values in your two-
dimensional array will accumulate these quantities as running totals.
Prompt the user to enter a value of zero (0) for the salesperson to stop processing input and have the program
produce the sales report. To produce the sales report, your program will pass the two-dimensional array
containing sales totals to a function named displayReport, whose only task is to display the report.
The displayReport function will receive a single parameter variable, the two-dimensional array. You will
determine how many rows there are in the array and how many columns there are in the array within the
displayReport function. You can use the length attribute associated with Java arrays. An array’s size is
available as an instance variable named length. You will not pass the number of rows or columns to the
displayReport function as additional parameter variables. You will not declare the number of rows and columns
in the array as global variables. Your program does not magically know there are 3 rows and 4 columns in the
array. Do not explicitly use 3 for the number of rows or 4 for the number of columns. Use variables. Our
textbook contains examples of how to compute row totals and column totals for a two-dimensional array. Feel
free to use the textbook. Stay away from the Internet. Solve this problem using your own best efforts.
Your displayReport function will display the individual and total sales for each product and salesperson. After
displaying this information, your program will identify the salesperson with the highest total sales. The initial
output from your program will consist of any warnings identifying bad entry values and a line displaying the
total number of user entries processed and the number of entries skipped for one reason or another. Model your
output, sales report display, and identification of the most successful salesperson after the following example:
Typical screen display:
Warning: Product must be a number from 1 to 4.
Warning: Salesperson must be a number from 1 to 3.
Warning: Quantity must be a positive number.
Of the 19 records processed, 3 were skipped.
S A L E S R E P O R T
Product 1 Product 2 Product 3 Product 4 Totals:
Salesperson 1 50 150 125 75 400
Salesperson 2 200 25 175 50 450
Salesperson 3 100 120 150 200 570
Totals: 350 295 450 325

Salesperson 3 had the highest total sales.


To receive full credit for this programming assignment, you must:
 Use the correct file name. For example, a student named John Jones will name his file,
“JJProjectTwo.java”.
 Submit a program that executes correctly. (No syntax or execution errors)

Grading Guideline:
 Correctly name the file submitted. (5 points)
 Include a comment containing the student’s full name in the program. (5 points)
 Process, correctly count, and display the total number of user entries. (10 points)
 Detect and skip records that are not valid. (5 points)
 Keep track of and display the number of user entries that were skipped. (5 points)
 Correctly determine the number of rows and the number of columns in the array passed to the
displayReport function without passing additional parameters or using global variables. (10 points)
 Use a function named displayReport that receives a single argument as requested. (10 points)
 Correctly accumulate and display the values for each product. (10 points)
 Correctly accumulate and display the values for each salesperson. (10 points)
 Correctly accumulate and display the totals for each product. (10 points)
 Correctly accumulate and display the totals for each salesperson. (10 points)
 Correctly determine and display the salesperson with the highest sales. (10 points)

You might also like