merchant problem, Basic Computer Science

Assignment Help:
Pebble Merchant
Problem Description
There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that and the mistakes result in losses. So, he comes to you, and asks you to make a small intelligent car, which could run along the room’s walls and calculate their length. The car has to come back from where it’s started. This means the starting point is the same as the ending one. When the car gives the length of the room’s walls, you could calculate the surface area of the floor. Knowing the surface area, you could calculate the price for covering the whole floor with pebbles.

3 kilograms of pebbles are needed for covering an area of 1 square meter .
The rate of the pebbles is $5 per kilogram.

For example

The car’s measurements are illustrated, using two arrays.

Array 1 = {L, R, L, R, R, L, R, R, L, R, R, L, R, L, L, R, Z}

Where

L denotes, that the car turned Left.
R denotes, that the car turned Right.
Z denotes, that the finishing point is after the last turn.

The following picture will clear any misunderstandings (on this example Array 1 = {L,R,R,R,Z})


Array 2 = {3, 4, 2, 3, 2, 4, 5, 4, 2, 3, 2, 1, 2, 2, 2, 1, 2}

An element of Array 2 denotes the length (in meters), covered by the car, after taking the corresponding turn.

{3L, 4R, 2L, 3R, 2R, 4L, 5R, 4R, 2L, 3R, 2R, 1L, 2R, 2L, 2L, 1R, 2Z}

In this representation it is clearly visible that the direction from entry turning point is measured, along with the distance to the next turning point.

The last element Z in Array 1 represents that the corresponding length in the Array 2 is the final distance and the car will be at finishing point after covering this length.



The area of the given picture is 63 square meters and the cost for covering it is $945.
Instructions to work with Open PBT Client:
1. Specify the work directory path in the ''''Work directory Path'''' field. The path should correspond to your solution work directory.
2. Download the support files by clicking the Get Dev Files.
3. You will find the problem directories containing:
o problem.h file
o problem.c file
in your project directory.
4. Code the solution in .c file inside the problem directory
5. All required files will be downloaded to your work directory. Creating additional files is strongly discouraged.
Step 1:
In your Solution File:
• Implement your logic in the function int * findCost(char direction[],int length[]).
• char direction[] : is a character array which represents turning direction of car.
• int length[] : is an integer array, which represents the length, traveled by the car, in each direction.
• You can create more functions if required, but those functions should be in the same file.

Step 2:
Your solution needs to consider the following constraints.
1. In this problem you have to make a program for the pebble merchant.
2. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that and the mistakes result in losses.
3. So, he comes to you and asks you to make a small intelligent car, which could run along the room’s walls and calculate their length.
4. The car has to come back from where it started.
5. This means the starting point is the same as the ending one.
6. The direction array contains only L, R and Z in UPPER CASE; otherwise return {0,0}
The Prototype of the function is
int * findCost(char direction[],int length[]).
This method takes the following arguments:
• direction is a character array, which represents the turning directions of the car.
• length is an integer array, which represents the length, traveled by the car, in each direction.

• This method returns an integer array having two elements first is the calculated area and second is the estimated cost.
The constraints are:
1. The direction array contains only L, R and Z in UPPER CASE; otherwise return {0,0}
2. The direction array''''s last element should be Z; otherwise return {0,0}
3. Each element in the length array should be greater than 0; otherwise return {0,0}
Example 1
Input
________________________________________
direction[] = {L,R,R,L,L,R,R,R,R,L,Z}
length[]= {2,2,1,1,1,2,5,2,2,3,1}
Output
________________________________________
{18,270}
Explanation : The area of the resultant figure is 18 square meters and the cost for covering it is $270.
Example 2
Input
________________________________________
direction[] = {L,L,R,R,L,R,R,L,R,L,R,R,L,R,L,R,R,L,Z}
length[]= {1,1,1,1,2,2,2,2,1,2,1,2,2,1,1,1,1,2,2}
Output
________________________________________
{24,360}
Example 3
Input
________________________________________
direction[] = {L,R,L,R,R,L,R,R,L,R,A,L,Z}
length[]= {1,2,2,2,2,2,5,2,1,2,3,2,2}
Output
________________________________________
{0,0}
For C solutions
Header File : pebblemerchant.h
Function Name : int * findCost(char direction[],int length[])
File Name : pebblemerchant.c
For C++ solutions
Header File : pebblemerchant.h
Class Name : PebbleMerchant
Function Name : int * findCost(char direction[],int length[])
File Name : pebblemerchant.c
General Instructions
* The file / class names, functions, method signatures, header files are to be used as mentioned in the problem statement. Do not use your own names or change the method signatures and fields. You can add any number of additional methods.
* For C solutions, change the value of "C_OR_CPP" macro in header file as 1 and for C++ solutions change the value as 2.
* Incase of iostream.h specify as iostream only.
* Command line options for the main() function are not supported currently.

Related Discussions:- merchant problem

Input/output (i/o) unit, Input/output (I/o) unit: This unit provides th...

Input/output (I/o) unit: This unit provides the interface between the computer and the computer peripherals. A computer peripheral is any unit, which is attached to, but is no

What is mixing, Question 1 Briefly explain waveform Characteristics ...

Question 1 Briefly explain waveform Characteristics Question 2 Write a note on: types of Microphones Question 3 Briefly explain Magnetic Properties of Audiotape

Explain briefly about das, Question 1 What is Content Addressable Storage?...

Question 1 What is Content Addressable Storage? Explain the elements of Content Addressable Storage Question 2 Explain briefly about DAS Question 3 Explain about N

Ip addressing assignment help, An IP address consists of 4 contiguous octet...

An IP address consists of 4 contiguous octets and is generally written in Dotted Decimal Notation in the form: A.B.C.D Where: A represents the most significant octet, D the leas

Project management, #Assignment 1: Project Management and Information Secur...

#Assignment 1: Project Management and Information Security Write a two to three (2-3) page paper that addresses the following: Explicate in detail the importance of project managem

Necessary nurses records, Necessary Nurses Records The software shoul...

Necessary Nurses Records The software should generate all registers/reports in detail summary for various permutations and combinations of options. A powerful SQL (Structure

Multiple queues, I need to create mulitple queues assignment that run concu...

I need to create mulitple queues assignment that run concurrently. It is like a queue simulation with  number of checkouts with a random probability of clients, joining any one

Process control management, Process Control Management:   A  process  ...

Process Control Management:   A  process  is an executing program. It is considered the standard unit of work within a computer system. Every executing program is treated as a

Syntax - programming language, Syntax: Syntax provides the structure a...

Syntax: Syntax provides the structure and how to formulate the phrase or sentence w.r.t grammar of the language. It tells us about which composition is allowed from the charac

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd