## help me for an programming contest .., C/C++ Programming

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.
3. You will find the problem directories containing:
o problem.h file
o problem.c file
4. Code the solution in .c file inside the problem directory
Step 1:
• 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
Function Name : int * findCost(char direction[],int length[])
File Name : pebblemerchant.c
For C++ solutions
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.

#### Support for object oriented program, support for object oriented program

support for object oriented program

#### Described inline function?, A: The inline keyword tells the compiler to sub...

A: The inline keyword tells the compiler to substitute the code in the function de_nition for each instance of a function call. Though, substitution takes place only at the compile

#### Write a program to illustrate passing structure to function, Write a Progra...

Write a Program to illustrate passing structure to function? # include struct customer { int id; char name; }; void func_struct(struct customer); main() { struct c

#### Program for design and simulate a basic risc processor, Overall Program Obj...

Overall Program Objective: You will design and simulate a basic RISC processor.   You will create and encode an instruction set.  Your final task will be to "compile" a program

#### What should one catch?, A: By keeping along with the C++ tradition of "ther...

A: By keeping along with the C++ tradition of "there's more than one method to do that" (translation: "give programmers options & tradeoffs so they can choose what's best for them

#### #title.jewel polish., Ask questionByteland county is very famous for lumino...

Ask questionByteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular

#### Program to open a file in c++, Program to Open a file in C++: int main...

Program to Open a file in C++: int main() {                  char ch;                  ifstream f1 ("OLDFILE.TXT");                  ofstream f2 ("NEWFILE.TXT");

#### Matrix transposition cipher, write a C rpogram that can display the transpo...

write a C rpogram that can display the transpose form of a ciphertext matrix.Prompt users to provide row and coloumn number of matrix.Then user will input plaintext and the program

#### Explain the ways of initializing the arrays, Various ways of initializing t...

Various ways of initializing the Arrays. - The for loop initializes 10 elements with the value of their index.      void main()     {                 const in

#### Basic date manipulation operation, pls help me to decode this.

pls help me to decode this.  