Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ImplementAnalyzerclass with asolvermethod. 1.Thesolvermethod returns amapwith a name of the weekday as the key for passed orders. 2.Thesolvermethod returns an average order quantity for a

ImplementAnalyzerclass with asolvermethod.

1.Thesolvermethod returns amapwith a name of the weekday as the key for passed orders.

2.Thesolvermethod returns an average order quantity for a given product id as a value for passed orders.

3.Thesolvermethod returns an average value rounded to the nearest integer (half up rounding).

4.Thesolvermethod always returns amap. If the method doesn't return anymapfor a given weekday, there shouldn't be any entry in the resulting map or there is an entry with a0value.

Example output

Your implementation should return following output forproductId=9872for example data:

{  "MONDAY" : 3, "TUESDAY" : 0, "WEDNESDAY" : 0, "THURSDAY" : 0, "FRIDAY" : 0, "SATURDAY" : 3,  "SUNDAY" : 4 } 

In the example above, there are two orders placed on Saturday: of3and2quantities. The average quantity is rounded to the nearest integer is3.

Example input

Orders collection:

[  {  orderId: 554,  creationDate: "2017-03-25T10:35:20", // Saturday  orderLines: [  {productId: 9872, name: 'Pencil', quantity: 3, unitPrice: 3.00}  ]  },  {  orderId: 555,  creationDate: "2017-03-25T11:24:20", // Saturday  orderLines: [  {productId: 9872, name: 'Pencil', quantity: 2, unitPrice: 3.00},  {productId: 1746, name: 'Eraser', quantity: 1, unitPrice: 1.00}  ]  },  {  orderId: 453,  creationDate: "2017-03-27T14:53:12", // Monday  orderLines: [  {productId: 5723, name: 'Pen', quantity: 4, unitPrice: 4.22},  {productId: 9872, name: 'Pencil', quantity: 3, unitPrice: 3.12},  {productId: 3433, name: 'Erasers Set', quantity: 1, unitPrice: 6.15}  ]  },  {  orderId: 431,  creationDate: "2017-03-20T12:15:02", // Monday  orderLines: [  {productId: 5723, name: 'Pen', quantity: 7, unitPrice: 4.22},  {productId: 3433, name: 'Erasers Set', quantity: 2, unitPrice: 6.15}  ]  },  {  orderId: 690,  creationDate: "2017-03-26T11:14:00", // Sunday  orderLines: [  {productId: 9872, name: 'Pencil', quantity: 4, unitPrice: 3.12},  {productId: 4098, name: 'Marker', quantity: 5, unitPrice: 4.50}  ]  } ]; 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions