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.
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:- help me for an programming contest ..

C++, #questAt a shop of marbles, packs of marbles are prepared. Packets are...

#questAt a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets wit

What is structure, What is Structure? An Array is a data structure who...

What is Structure? An Array is a data structure whose elements are all of the similar data type. The structure is a data structure whose individual elements are able to differ

Tells the operators one can override; which operators , Q:  Tells the opera...

Q:  Tells the operators one can override; which operators should he override? A: Bottom line: don't puzzle your users. Remember the reason of operator overloading: to decreas

Area, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Explain the scope resolution operator, The Scope Resolution Operator( :: ) ...

The Scope Resolution Operator( :: ) Global variables are explained outside any functions and thus can be used by all the functions defined thereafter. However, if a global vari

Computer, Is computer an intelligent machine?

Is computer an intelligent machine?

C program to create a file student.dat, Program is to create a file student...

Program is to create a file student.dat: Program is to create a file student.dat which contains all name, roll_no,marks(5 sub) and percentage   class student    {

Recursive procedure to computes the number of digits, (a) Write a recursive...

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit

How do you access the values within an array, How do you access the values ...

How do you access the values within an array? - Arrays comprise a number of elements, which depends on the size you assigned it during variable declaration. - Every element

Equation, My project is compiling but the equation entered is not working

My project is compiling but the equation entered is not working

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