Question: Use IntelliJ IDEA to write a java program named FootTrafficFinal that follows the instructions below. When your program is complete, export your project to zip
Use IntelliJ IDEA to write a java program named FootTrafficFinal that follows the instructions below. When your program is complete, export your project to zip and upload the file to the CANVAS Final Exam dropbox. As a programming assignment, remember to follow typical instructions and include your name, accessID, and date. Also please follow good programming style practices and include comments along with your code for full credit!
Problem Description:
Stores frequently monitor how many people come into their stores. You are going to write a program that monitors how many people came into the store a given day. Follow the instructions below to code the FootTrafficFinal program.
Main Method:
Call the getNumOfDays method.
Call the generateTrafficData method.
Call the writeTrafficData method.
Call the readTrafficData method.
Call the printHistogram method.
Other Methods:
getNumOfDays method. This method does not receive any parameters. It prompts the user: Enter the number of days to evaluate inclusive:
The method loops until the user enters a valid integer between and inclusive. It returns the number of days as numOfDays.
generateTrafficData method. This method receives numOfDays. It generates amount of people entering the store and stores it in an integer array.
Specifically, it uses the random number equation to generate sales data between and So for example, if numOfDays 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 footTraffic.
writeTrafficData method. This method receives the footTraffic array. It writes the data to a file called traffictxt It returns nothing. It writes each number from the array to its own line in a file named "traffic.txt Use a trycatch block to catch a FileNotFoundException and output the file not found exception message.
readtrafficData method. This method receives the name of the file to read. It reads the traffictxt file. It creates an integer ArrayList called trafficData that contains the contents of the traffic.txt file. It calls the calcAvgTraffic method.
It returns the trafficData ArrayList. Use a trycatch block to catch a FileNotFoundException. Output the file not found exception message if it occurs.
calcAvgTraffic method. This method receives the trafficData ArrayList. It calculates the average number of people entering and prints this information to the console. For example, if trafficData is then it outputs:
The average number of people entering the store per day is
printHistogram method. This method receives trafficData and numOfDays. It returns nothing. It prints a histogram that depicts the number of people enter the store each day.
For example, if trafficData is
The output should be:
People entered on Day
People entered on Day
People entered on Day
People entered on Day
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
