Question: Use IntelliJ to write a java program named CarSalesFinal that follows the instructions below. When your program is complete, export yourproject to zip and upload
Use IntelliJ to write a java program named CarSalesFinal that follows the instructions below. When your program is complete, export yourproject to zip and upload the file to the CANVAS Final Exam dropbox. As a programming assignment, remember to follow typical instructionsand include your name, accessID, and date. Also please follow good programming style practices and include comments along with yourcode for full credit!
Problem Description:
Assume you manage a car sales department. You need a simple application that tracks the number of cars sold by agiven employee. Follow the instructions below to code the CarSalesFinal program.
Main Method:
Call the getNumOfMonths method.
Call the generateSalesData method.
Call the writeSalesDatamethod.
Call the readSalesData method.
Call the printHistogram method.
Other Methods:
getNumOfMonths method. This method does not receive any parameters. It prompts the user: Enter the number ofmonths to evaluate sales data inclusive:
The method loops until the user enters a valid integer between and inclusive. It returns the number of months asnumOfMonths.
generateSalesData method. This method receives numOfMonths. It generates sales data and stores it in an integerarray.
Specifically, it uses the random number equation to generate sales data between and So for example, ifnumOfMonths is then this method creates an integer array with a size of generates integers between and and stores each number in the array. It returns the array as monthlySales.
writeSalesData method. This method receives the monthlySales array. It writes the data to a file called salestxt Itreturns nothing. It writes each number from the array to its own line in a file named "sales.txt Use a trycatch block tocatch a FileNotFoundException and output the file not found exception message.
readSalesData method. This method receives the name of the file to read. It reads the salestxt file. It creates aninteger ArrayList called salesData that contains the contents of the sales.txt file. It calls the calcAvgSales method.
It returns the salesData ArrayList. Use a trycatch block to catch a FileNotFoundException. Output the file not foundexception message if it occurs.
calcAvgSales method. This method receives the salesData ArrayList. It calculates the average number of cars soldand prints this information to the console. For example, if if salesData is then it outputs:
The average number of cars sold per month is
printHistogram method. This method receives salesData and numOfMonths. It returns nothing. It prints a histogramthat depicts the number of cars sold each month.
For example, if salesData is
The output should be:
Cars Sold Month
Cars Sold Month
Cars Sold Month
Cars Sold Month
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
