Question: Using Java Question Part 1: Create the VehicleSalesAnalysis class, you can start by modifying Ch9-PC11 (Sales Analysis class). Use your Vehicle class to help you

Using Java

Question Part 1:

Create the VehicleSalesAnalysis class, you can start by modifying Ch9-PC11 (Sales Analysis class). Use your Vehicle class to help you analyze the data. Use the Month class to deal with the user input, i.e. allow the user to use numbers or month names. The user should be asked to enter the month to be analyzed. Only the numbers for the vehicles sold should be included in the totals. The class should output: total retail sales for the month, total commercial sales for the month and grand total sales for the month, as well as the number of vehicles sold in each category. You will be provided with a test file that will hold information for a vehicle in each line. The first line will be a header line, the file will be delimited with comas , to separate the vehicles information. The format will be the same as the class you wrote in PB10

Sample output Sales for October:

Categories Sales Number of Sold

______________________________________________________

Total $1,245,145.25 13

Commercial $504,455.75 3

Retail $740,689.50 10

Question Part 2:

-------------------------------------------------- CH9 PC 11 ----------------------------------------------------------------------------

The file SalesData.txt, in this chapters source code folder, contains the dollar amoung of sales that a reatil store made each day for a number of weels. Each line in the file contains seven numbers, which are the sales numbers for 1 week. The numbers are separated by a comma.

1245.67,1490.07,1679.87,2371.46,1783.92,1461.99,2059.77 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36 2513.45,1963.22,1568.35,1966.35,1893.25,1025.36,1128.36

Write a program that opens the file and processes its contents. The program should display the following:

- The total sales for each week

- The average daily sales for each week

- The total sales for all of the weeks

- The average weekly sales

- The week number that had the highest amount of sales

- The week number that had the lowest amount of sales

-------------------------------------------------------------------------- Month Class --------------------------------------------------------------------

public class Month {

// Class variable private static final String[] MONTH_NAME = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; // Instance variables private int monthNumber;

/** * Default constructor */ public Month() { this.monthNumber = 1; }

/** * Parameterized constructor * @param monthNumber */ public Month(int monthNumber) { setMonthNumber(monthNumber); } /** * Parameterized constructor * @param monthNumber */ public Month(String monthName) { int monthNumber = 0; for (String month : Month.MONTH_NAME) { monthNumber += 1; if(monthName.equalsIgnoreCase(month)) { this.monthNumber = monthNumber; break; } } }

/** * Returns the monthNumber */ public int getMonthNumber() { return monthNumber; }

/** * @param monthNumber the monthNumber to set */ public void setMonthNumber(int monthNumber) { if((monthNumber < 1) || (monthNumber > 12)) this.monthNumber = 1; else this.monthNumber = monthNumber; } /** * Returns the monthName */ public String getMonthName() { return MONTH_NAME[this.monthNumber - 1]; }

@Override public String toString() { return getMonthName(); }

public boolean equals(Month month) { if(month != null) { if((this == month) || (this.monthNumber == month.monthNumber)) return true; } return false; } /** * Returns true if the calling object's month is greater than the argument's month * @param month * @return */ public boolean greaterThan(Month month) { return this.monthNumber > month.monthNumber; } /** * Returns true if the calling object's month is less than the argument's month * @param month * @return */ public boolean lessThan(Month month) { return this.monthNumber < month.monthNumber; } }

----------------------------------------------- PB 10 Format -------------------------------------------------------------------

public class Vehicle { private String make, model, style, agentID; private int vinNumber, month; private double price; private boolean sold; public Vehicle() { } public Vehicle(String make, String model, String style,int vinNumber, double price, boolean sold, int month, String agentId){ this.model = model; this.make = make; this.style = style; this.vinNumber = vinNumber; this.price = price; this.sold = sold; this.month = month; this.agentID = agentId; } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getStyle() { return style; } public void setStyle(String style) { this.style = style; } public String getAgentID() { return agentID; } public void setAgentID(String agentID) { this.agentID = agentID; } public int getVinNumber() { return vinNumber; } public void setVinNumber(int vinNumber) { this.vinNumber = vinNumber; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public boolean isSold() { return sold; } public void setSold(boolean sold) { this.sold = sold; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!