Questions
Q, Haskell. I need to define function encode and decode. Details about the functions are provided...

Q, Haskell.

I need to define function encode and decode. Details about the functions are provided in code.

-- | encode
--
-- Given a string, return a list of encoded values of type (Int,Char)
--
-- >>> encode ['a','a','a','a','b','c','c','a','a','d','e','e','e','e']
-- [(4,'a'),(1,'b'),(2,'c'),(2,'a'),(1,'d'),(4,'e')]
--
-- >>> encode "hello"
-- [(1,'h'),(1,'e'),(2,'l'),(1,'o')]
--
-- >>> encode []
-- []
--
encode :: String -> [(Int,Char)]
encode = undefined

-- | decode
--
-- Given a list of encoded values of type (Int,Char), generate a string corresponding to
-- this encoding.
--
-- If the first element of any pair in the list is equal to zero or negative, 
-- skip the corresponding character in the output string, 
-- while still providing decodings for the remaining characters.
-- 
--
-- >>> decode [(4,'a'),(1,'b'),(2,'c'),(2,'a'),(1,'d'),(4,'e')]
-- "aaaabccaadeeee"
--
-- >>> decode []
-- ""
--
-- >>> decode [(-4,'a')]
-- ""
--
-- >>> decode [(3,'c'),(-4,'a'),(5,'b')]
-- "cccbbbbb"
--
-- >>>decode [(3,'c'),(0,'a'),(5,'b')]
-- "cccbbbbb"
--
-- prop> \x -> x == decode (encode x)
-- 
decode :: [(Int,Char)] -> String
decode = undefined

In: Computer Science

You need to create a Java class library to support a program to simulate a Point-...

You need to create a Java class library to support a program to simulate a Point- of-Sale (POS) system.

General Requirements:

  • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand;

  • You should create identifiers with sensible names;

  • You should make comments to describe your code segments where they are necessary for

    readers to understand what your code intends to achieve.

  • Logical structures and statements are properly used for specific purposes.

  • Program Requirements

  1. You create three classes: ProductPrices, ShoppingCart and CashRegister in the filePOSLib.java to support a POS system implemented in the program POSmain.java, which is provided.

    The POSmain program takes three file names from command line arguments. The first file contains a list of products and their prices; the second and third files are lists of items in two shopping carts of two customers. The POSmain program should first read the price file, then read each of the cart files to load a list of items in a shopping cart and store them in a ShoppingCartobjects. The price file may contain a variable number of products and the cart files may contain a variable number of items.

    POSmain then will create a CashRegister object by passing the price list to it. The POSmainprogram then will use the CashRegister object to scan items in a cart and print a receipt for each shopping cart one by one. At last, POSmain will use the CashRegister object to print a report for the day.

    The three classes you will create are described in the following UML design class diagrams. You must implement all specified fields and methods in the classes. You are free to add private fields and methods to CashRegister class if appropriate.

ProductPrices
-products: ArrayList<String>
-prices: ArrayList<Double>

+put(String product, double price)
+get(String product): double
  • The put method will store the price for the product in the products and prices fields, respectively;

  • The get method will return the price for the product.

ShoppingCart
-items: ArrayList<String>
+addItem(String): void
+getAllItems(): ArrayList<String>
  • The addItem method will add the product to the shopping cart;

  • The getAllItems method will return all items in the shopping cart.

CashRegister
  
-productPrices: ProductPrices
......
+CashRegister(ProductPrices)
+scanAllItemsInCart(ShoppingCart): void
+printReceipt(): void
+printReportForTheDay(): void
......
  • The constructor will initialise the CashRegister object with the product prices;

  • The scanAllItemsInCart will examine all items in the shopping cart and prepare to

    print the receipt for the shopping cart and report for the day;

  • The printReceipt method will print the product name, price, quantity, subtotal, and

    total purchase for a shopping cart in the alphabetical order of the product names. Refer to the Testing section for the receipt format;

  • • The printReportForTheDay method will print a report for the day in the alphabetical order of the product names for the cash register. Refer to the Testing section for the report format.

  • You need to understand the POSmain program and observe the sample output in the Testing section to understand more how the program will work with the classes.

In: Computer Science

The academic, inventory, and financial information at the CSE (Computer Science and Engineering) department of a...

The academic, inventory, and financial information at the CSE (Computer Science and Engineering) department of a certain institute was being carried out manually by two office clerks, a store keeper, and two attendants. The department has a student strength of 500 and a teacher strength of 30. The head of the department (HoD) wants to automate the office work. Considering the low budget that he has at his disposal, he entrusted the work to a team of student volunteers. For requirements gathering, a member of the team who was responsible for requirements analysis and specification (analyst) was first briefed by the HoD about the specific activities to be automated. The HoD mentioned that three main aspects of the office work needs to be automated—stores-related activities, student grading activities, and student leave management activities. It was necessary for the analyst to meet the other categories of users. The HoD introduced the analyst (a student) to the office staff. The analyst first discussed with the two clerks regarding their specific responsibilities (tasks) that were required to be automated. For each task, they asked the clerks to brief them about the steps through which these are carried out. The analyst also enquired about the various scenarios that might arise for each task. The analyst collected all types of forms that were being used by the student and the staff of the department to register various types of information with the office (e.g. student course registration, course grading) or requests for some specific service (e.g. issue of items from store). He also collected samples of various types of documents (outputs) the clerks were preparing. Some of these had specific printed forms that the clerks filled up manually, and others were entered using a spreadsheet, and then printed out on a laser printer. Fo r each output form, the analyst consulted the clerks regarding how these different entries are generated from the input data. The analyst met the store keeper and enquired about the material issue procedures, store ledger entry procedures, and the procedures for raising indents on various vendors. He also collected copies of all the relevant forms that were being used by the store keeper. The analyst also interviewed the student and faculty representatives. Since it was needed to automate the existing activities of an working office, the analyst could without much difficulty obtain the exact formats of the input data, output data, and the precise description of the existing office procedures.

1. Draw use case and class diagram.

2. Write 5 functional and non-functional requirements.

In: Computer Science

When multimedia developers produce Bitmapped Images, they must consider that a bitmapped image is device-dependent. For...

When multimedia developers produce Bitmapped Images, they must consider that a bitmapped image is device-dependent. For that reason, they often need to produce multiple bitmapped images that have different spatial resolutions based on their intended use. For example, they produce a bitmapped image to be printed, and reduce its spatial resolution to be displayed on monitors.

What does it mean to say that a bitmapped image is device-dependent? Explain why different resolutions of bitmapped images are needed for different devices such as monitors and printers.

Please write, not a screenshot

In: Computer Science

Q.n.5) In "Extraction of DNA from Straberries, and precipitation of DNA", Write a short description of...

Q.n.5) In "Extraction of DNA from Straberries, and precipitation of DNA", Write a short description of the DNA.

In: Chemistry

No hand writing and pictures please. Illustrate the concept of ROI with suitable numerical example. How...

No hand writing and pictures please.

  1. Illustrate the concept of ROI with suitable numerical example. How ROI is different from Residual Income? Explain in your own words.

In: Accounting

6.explain characterizing schedules based on recoverability and serialibality.(50marks) Need own answer and no internet answers r...

6.explain characterizing schedules based on recoverability and serialibality.(50marks)

Need own answer and no internet answers r else i il downvote nd report to chegg.Even a single is wrong i il downvote.its 50marks question so no short answer minimum 10page answer required and own answer r else i il downvote.

Note:Minimum 10page answer and no plagarism r else i il downvote and report to chegg.Minimum 10 to 15page answer required r else dnt attempt.strictly no internet answer n no plagarism.

its 50marks question so i il stricly review nd report

Note:Its already there in chegg and its wrong answer i need own answer and correct answer r else i il downvote

In: Computer Science

Imagine a situation that you are on an island in the middle of a sea ....

Imagine a situation that you are on an island in the middle of a sea . The island is of around 10km long and put one transmitting antenna at one end of the island and another receiving antenna at the other island. The island has no man-made infrastructure but has trees, plants and animals. List the types of attenuation that the transmission signals will suffer and explain why?

In: Computer Science

Q1: The expression A = (E – F)/((P + (3*Q))*((2*R) – (5*S))) is not a valid...

Q1: The expression A = (E – F)/((P + (3*Q))*((2*R) – (5*S))) is not a valid SPLan assignment statement. Write a sequence of assignment statements that will perform the equivalent calculation.

Q2: Write a program which asks the user to input an integer. If the integer is less than zero, the program should output the message “Negative, the absolute value is ”, followed by the absolute value of the number. If the input is zero, the program should output the message “Zero.” If the input is greater than zero, the program should output the message “Positive.”

In: Computer Science

Does the United States have any ethical duties to undocumented (illegal) aliens who come here to...

Does the United States have any ethical duties to undocumented (illegal) aliens who come here to work? How can the law be fair and balance the rights of immigrants, their families, the companies that employ them, and U. S. citizens??

In: Operations Management

Using*************** C++ **************** explain what Objects and Classes are. Please describe in detail.

Using*************** C++ **************** explain what Objects and Classes are. Please describe in detail.

In: Computer Science

roduction Budget and Direct Materials Purchases Budgets Peanut Land Inc. produces all-natural organic peanut butter. The...

roduction Budget and Direct Materials Purchases Budgets

Peanut Land Inc. produces all-natural organic peanut butter. The peanut butter is sold in 12-ounce jars. The sales budget for the first four months of the year is as follows:

Unit Sales Dollar Sales ($)
January 60,000 114,000
February 65,000 123,500
March 70,000 133,000
April 46,000 87,400

Company policy requires that ending inventories for each month be 15% of next month's sales. At the beginning of January, the inventory of peanut butter is 38,000 jars.

Each jar of peanut butter needs two raw materials: 24 ounces of peanuts and one jar. Company policy requires that ending inventories of raw materials for each month be 20% of the next month's production needs. That policy was met on January 1.

Required:

1. Prepare a production budget for the first quarter of the year. Show the number of jars that should be produced each month as well as for the quarter in total.

Peanut Land Inc.
Production Budget
For the First Quarter of the Year
January February March Total
Sales
Desired ending inventory
Total needs
Less: Beginning inventory
Units produced

Feedback

The production budget is in units. Fill in the units for sales from the amounts provided. The desired ending inventory is added to the number of units to be produced and is calculated based on future sales. Beginning inventory is subtracted to determine units to be produced. Beginning inventory is given for the first month and is carried forward from the previous month for later months.

Review the "How to Prepare a Production Budget" example in the text.

2. Prepare a direct materials purchases budget for jars for the months of January and February.

Peanut Land Inc.
Direct Materials Purchases Budget for Jars
For January and February
January February Total
Production
Jar
Jars for production
Desired ending inventory
Total needs
Less: Beginning inventory
Jars purchased

Feedback

Fill in the units produced from Requirement 1.

Production in units x Materials per unit = Direct Materials Needed for Production

The desired ending inventory for materials is added to the materials to be purchased and is calculated based on future production. Note that the percentage of desired materials inventory does not match the percentage of desired completed inventory. Beginning inventory is calculated from current month production for the first month and is carried forward from the previous month for later months.

Direct Materials Needed for Production + Direct Materials in Desired Ending Inventory – Direct Materials in Beginning Inventory = Purchases

Review the "How to Prepare a Direct Materials Purchases Budget" example in the text.

Prepare a direct materials purchases budget for peanuts for the months of January and February.

Peanut Land Inc.
Direct Materials Purchases Budget for Peanuts
For January and February
January February Total
Production
Ounces
Ounces for production
Desired ending inventory
Total needs
Less: Beginning inventory
Ounces purchased

In: Accounting

Dieckman Company makes a product with the following costs: Per Unit Per Year   Direct materials $17.90...

Dieckman Company makes a product with the following costs:

Per Unit Per Year
  Direct materials $17.90     
  Direct labor $11.20     
  Variable manufacturing overhead $3.70     
  Fixed manufacturing overhead $716,900   
  Variable selling and administrative expenses $1.00     
  Fixed selling and administrative expenses $770,000   

The company uses the absorption costing approach to cost-plus pricing described in the text. The pricing calculations are based on budgeted production and sales of 67,000 units per year.

The company has invested $370,000 in this product and expects a return on investment of 17%.

Direct labor is a variable cost in this company.
The markup on absorption cost is closest to: (Round your intermediate calculations to 2 decimal places and final answers to 1 decimal place.)

77.6%

28.7%

17.0%

30.9%

In: Accounting

Compare and contrast the two types of diversification strategies. Identify a firm that has recently engaged...

Compare and contrast the two types of diversification strategies. Identify a firm that has recently engaged in each type of diversification. Search each firm’s website to identify executives’ rationale for diversifying. Do you find the reasoning to be convincing? Why or why not?

In: Operations Management

how globalization has “flattened” the world?

how globalization has “flattened” the world?

In: Operations Management