You are given an HTML document containing a two-dimensional table. Each row of this table consists...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are given an HTML document containing a two-dimensional table. Each row of this table consists of three cells containing information about a single loan of a book: • name of the customer; • date the book was borrowed (in ISO 8601 format); • date the book was returned (this cell might be empty, which means that the book has not yet been returned). Rows containing the loans which are overdue should have a red background color. The loan is considered overdue if the book has been borrowed for strictly more than limit days. In other words, it was returned more than limit days after having been borrowed, or it was borrowed more than limit days ago and has not yet been returned. Your task is to write a function to test whether the table in the HTML document has been colored correctly according to the described schema; that is, whether only the rows containing overdue loans have a red background color. You should return the number of incorrectly marked rows. The table is created using table, tbody, tr and td tags. Each row marked in red will have a style property in a corresponding tr tag, in which the background-color CSS property is set to red; otherwise the background color of the row is not specified. Write a function: function solution (today, limit); that, given the current date in ISO 8601 format, today, and limit, the number of days after which a book is considered overdue, returns the number of incorrectly marked rows in the table provided in the HTML document. You may assume that the HTML document contains exactly one table. For example, given today = "2016-11-30", limit = 14 and a document which has the following table in its body: <table><tbody> <tr style="background-color: red"> <td>Donna</td> <td>2016-10-01</td> <td></td> </tr> <tr style="background-color: red"> <td>Nansen</td> <td>2016-11-05</td> <td>2016-11-14</td> </tr> <tr style="background-color: red"> <td>Peppe</td> <td>2016-11-05</td> <td>2016-11-14</td> </tr> <tr> <td>J'Sira</td> <td>2012-02-28</td> <td>2012-03-14</td> </tr> <tr> <td>Billie</td> <td>2015-08-14</td> <td>2015-10-09</td> </tr> <tr> <td>Peyton</td> <td>2015-08-14</td> <td>2015-10-09</td> </tr> </tbody></table> which, when displayed in a browser, produces the following output: Donna 2016-10-01 Nansen2016-11-052016-11-14 ||| <7 CD00Y7\7 caure. which, when displayed in a browser, produces the following output: Donna 2016-10-01 Nansen2016-11-052016-11-14 Peppe 2016-11-052016-11-14 J'Sira 2012-02-282012-03-14 Billie 2015-08-142015-10-09 Peyton 2015-08-142015-10-09 your function should return 5. The books in rows 1, 4, 5 and 6 are overdue. This means that the coloring of all the rows except the firs is incorrect. However, given today = "2015-11-30", limit = 7 and the following table in the document: <table><tbody> <tr> <td>Addison</td> <td>2014-08-14</td> <td>2014-10-09</td> </tr> <tr> <td>Val</td> <td>2014-08-14</td> <td>2014-10-09</td> </tr> <tr> <td>Patrick</td> <td>2015-11-23</td> <td></td> </tr> </tbody></table> which, when displayed in a browser, yields the following output: Addison2014-08-142014-10-09 Val 2014-08-142014-10-09 Patrick 2015-11-23 your function should return 2. The first two books are overdue and thus should have been marked in red. You are given an HTML document containing a two-dimensional table. Each row of this table consists of three cells containing information about a single loan of a book: • name of the customer; • date the book was borrowed (in ISO 8601 format); • date the book was returned (this cell might be empty, which means that the book has not yet been returned). Rows containing the loans which are overdue should have a red background color. The loan is considered overdue if the book has been borrowed for strictly more than limit days. In other words, it was returned more than limit days after having been borrowed, or it was borrowed more than limit days ago and has not yet been returned. Your task is to write a function to test whether the table in the HTML document has been colored correctly according to the described schema; that is, whether only the rows containing overdue loans have a red background color. You should return the number of incorrectly marked rows. The table is created using table, tbody, tr and td tags. Each row marked in red will have a style property in a corresponding tr tag, in which the background-color CSS property is set to red; otherwise the background color of the row is not specified. Write a function: function solution (today, limit); that, given the current date in ISO 8601 format, today, and limit, the number of days after which a book is considered overdue, returns the number of incorrectly marked rows in the table provided in the HTML document. You may assume that the HTML document contains exactly one table. For example, given today = "2016-11-30", limit = 14 and a document which has the following table in its body: <table><tbody> <tr style="background-color: red"> <td>Donna</td> <td>2016-10-01</td> <td></td> </tr> <tr style="background-color: red"> <td>Nansen</td> <td>2016-11-05</td> <td>2016-11-14</td> </tr> <tr style="background-color: red"> <td>Peppe</td> <td>2016-11-05</td> <td>2016-11-14</td> </tr> <tr> <td>J'Sira</td> <td>2012-02-28</td> <td>2012-03-14</td> </tr> <tr> <td>Billie</td> <td>2015-08-14</td> <td>2015-10-09</td> </tr> <tr> <td>Peyton</td> <td>2015-08-14</td> <td>2015-10-09</td> </tr> </tbody></table> which, when displayed in a browser, produces the following output: Donna 2016-10-01 Nansen2016-11-052016-11-14 ||| <7 CD00Y7\7 caure. which, when displayed in a browser, produces the following output: Donna 2016-10-01 Nansen2016-11-052016-11-14 Peppe 2016-11-052016-11-14 J'Sira 2012-02-282012-03-14 Billie 2015-08-142015-10-09 Peyton 2015-08-142015-10-09 your function should return 5. The books in rows 1, 4, 5 and 6 are overdue. This means that the coloring of all the rows except the firs is incorrect. However, given today = "2015-11-30", limit = 7 and the following table in the document: <table><tbody> <tr> <td>Addison</td> <td>2014-08-14</td> <td>2014-10-09</td> </tr> <tr> <td>Val</td> <td>2014-08-14</td> <td>2014-10-09</td> </tr> <tr> <td>Patrick</td> <td>2015-11-23</td> <td></td> </tr> </tbody></table> which, when displayed in a browser, yields the following output: Addison2014-08-142014-10-09 Val 2014-08-142014-10-09 Patrick 2015-11-23 your function should return 2. The first two books are overdue and thus should have been marked in red.
Expert Answer:
Answer rating: 100% (QA)
the following function returns the values of incorerctly colored rows function solutiontoday limit v... View the full answer
Related Book For
Algorithm Design And Applications
ISBN: 9781118335918
1st Edition
Authors: Michael T. Goodrich, Roberto Tamassia
Posted Date:
Students also viewed these accounting questions
-
You are given an M/M/2 queueing system with = 4 per hour and = 6 per hour. Determine the probability that an arriving customer will wait more than 30 minutes in the queue, given that at least 2...
-
You are given an M/M/1 queueing system with mean arrival rate and mean service rate . An arriving customer receives n dollars if n customers are already in the system. Determine the expected cost in...
-
You are given an annual time series with 40 consecutive values and asked to fit a fifth-order autoregressive model. a. How many comparisons are lost in developing the autoregressive model? b. How...
-
A hospital radiology department has the following activities: Activity Number Activity Description 1 Repair X-ray equipment 2 Taking X-ray with X-ray...
-
Financial statements for Askew Industries for 2011 are shown below: Required: Calculate the following ratios for 2011. 1. Inventory turnover ratio 2. Average days in inventory 3. Receivables turnover...
-
QP Corp. sold 4,000 units of its product at $50 per unit in year 2016 and incurred operating expenses of $5 per unit in selling the units. It began the year with 700 units in inventory and made...
-
The account balances for the year ended December 31,2010, for Williams Industries are listed next: Requirements 1. Prepare Williams Industries multi-step income statement. 2. Prepare Williams...
-
Using the Customers table in the BSN database that accompanies this book and following the directions in this chapter, create the form in Figure 9-1. Make sure that you reformat the default positions...
-
Answer the following questions below. 1. Every research needs to have a summary of what you gather or findings. Having this concept, how are you going to apply your findings in real life after your...
-
At the end of the day the clerk for Wales Variety Shop noticed an error in the amount of cash he should have. Total cash sales from the sales tape were $1,204, whereas the total cash in the register...
-
Why is the effect of persuasive communication so great/ or play a important role in the field of business administration?
-
What are the design considerations for absorption columns in large-scale industrial applications? Discuss the effects of tray design, packing materials, and column geometry on absorption efficiency...
-
NYK shipping line has quoted a Japanese exporter US $ 4750.00 for a 40 ft. container from Kobe to Toronto and the exporter agreed. The journey involves Ocean transportation from Kobe to Vancouver,...
-
There are two good toasters on the market today: The Super Deluxe Chromium Coated Premium Toaster ("Toaster A"), and the Aluminum Plated Cross-Hatched Toaster Extraordinaire ("Toaster B"). Each...
-
Write 4 paragraphs about 'modes of communication in Blackberry' with citation and references in APA style.
-
Silver Company makes a product that is very popular as a Mother's Day gift. Thus, peak sales occur in May of each year, as shown in the company's sales budget for the second quarter given below:...
-
Mercy West clinic uses patient visits as its measure of activity. The clinic has provided the following report: Mercy west clinic comparison of Planning Budget to Actual Results For the month ended...
-
Independent random samples of sizes n1 = 30 and n2 = 50 are taken from two normal populations having the means 1 = 78 and 2 = 75 and the variances 21 = 150 and 22 = 200. Use the results of Exercise...
-
Give an algorithm that computes a minimum cut of a graph with n vertices by O(n) applications of a maximum flow algorithm to a flow network derived from G.
-
Consider a single machine scheduling problem, where we are given a set, T, of tasks specified by their start times and finish times, as in the task scheduling problem, except now we have only one...
-
Suppose you have a collection, S, of n distinct items and you create a random sample, R, of S, as follows: For each x in S, select it to belong to R independently with probability 1/n 1/2 . Derive...
-
Discuss some of the special considerations involved in the audit of investments in group entities.
-
Joplin Ltds financial year ends on 30 June 20X1 and the companys auditor, Hagan and Partners, conducts the annual audit during July and August. Hagan and Partners has prepared auditing procedures for...
-
What is a solicitors representation letter? What effect might the failure of a solicitor to respond to a request for representation have on the auditors report?
Study smarter with the SolutionInn App