Login

Create Account
Customer Service Chat
+14156709189
info@expertsmind.com
Submit Homework/Assignment
Get quote & make Payment
Get Solution
help me for an programming contest .., C/C++ Programming
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.
Posted Date: 9/2/2012 3:37:10 PM  Location : United States
Ask an Expert
Related Discussions:
help me for an programming contest .., Assignment Help, Ask Question on help me for an programming contest .., Get Answer, Expert's Help, help me for an programming contest .. Discussions
Write discussion on help me for an programming contest ..
Your posts are moderated
Write your message here..
Related Questions
Solve, solve for radius(R) of a circle of its area is to be inputted by a u...
solve for radius(R) of a circle of its area is to be inputted by a user. also display compute the circle diameter hint: area= pir21 pi=2.1416
Pebble merchant, there is a pebble merchant. he sells the pebbles,that are ...
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 side but he sometines mistakes doing that and m
Common c control flow instructions, In this Lab you will code 8086 assemble...
In this Lab you will code 8086 assembler equivalents (Virgo) for common C control flow instructions. This will give you an appreciation for how control flow is implemented in assem
#title. RETIRED ON SOCIAL SECURITY., IS IT POSSIBLE FOR YOU TO WRITE A PR...
IS IT POSSIBLE FOR YOU TO WRITE A PROGRAM FOR ME TO MEASURE EXISTING ANGLES AND DO IF AND THEN FROM THIS , AND TO PLACE FIXED ANGLES AT CERTAIN POSITION AS A ADD WITH DLL FOR CERTA
Addition of array elements, Addition of array elements: #define rows 3 ...
Addition of array elements: #define rows 3 #define cols 3 void main() { int i=0,j=0,sum=0; int arr[rows][cols];
Example of pointers, #include "stdafx.h" #include iostream using name...
#include "stdafx.h" #include iostream using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int NumbHold[5]; int * ptrNumb;
MINIMUM SHELVES, Write a program to find minimum number of shelves
Write a program to find minimum number of shelves
Decision making and branching, how to present assinment
how to present assinment
Recursive function, Binomial coefficients are the numeric factors of the pr...
Binomial coefficients are the numeric factors of the products in a power of a binomial such as (x + y)n. For example, (x + y)2 = x2 + 2 x y + y2 has the coefficients 1 2 1. Binomia
Coding, dispaly the last ant on rod
dispaly the last ant on rod
Assignment Help
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
IT Courses and Help
ExpertsMind Services
Online Tutoring
Projects Assistance
Exam Preparation
Coursework Help
Programming Courses
Engineering Courses
Why Us ?
~Experienced Tutors
~24x7 hrs Support
~Plagiarism Free
~Quality of Work
~Time on Delivery
~Privacy of Work