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 ..

Create a programming system, Your task is to create a programming system fo...

Your task is to create a programming system for a ferry. The ferry transports passengers and vehicles (cars, busses, lorries and bicycles). The ferry has space for 200 passengers a

Introduction to c programming, How would you print the values of the variab...

How would you print the values of the variables words and lines so they appear in the form: There were 6040 words and 680 lines. Here, 6040 and 680 represent the values of the two

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Word counting, Task Your task is to write a program, words, that reports i...

Task Your task is to write a program, words, that reports information about the number of words read from its standard input. For example, if the file qbf.txtcontains the text th

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

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

3n+1, Consider the following algorithm to generate a sequence of numbers. S...

Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat this process wi

Client-server architecture Project, I need a client-server architecture pro...

I need a client-server architecture program for windows OS (minimum support: Win 7),. the agent program will run as a background process and perform certain tasks every X time, and

Algorithm, for different operation multiple stack

for different operation multiple stack

C, algo of stack using two queue

algo of stack using two queue

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