Discuss C++ problem i in the C/C++ Help forum on Dev Articles. C++ problem i C/C++ Help forum discussing building and maintaining applications in C/C++. Find out why these languages are the foundation on which other languages are built.

Posts: 1
Time spent in forums: 44 m 56 sec
Reputation Power: 0

Please i need help

Hi Every Body.

I want your help to program this problem if you don't mind

and thank you
==========================================

Scenario:
You are to help an electrician (shown in the picture below) to estimate the number of steps that he has to climb in order to replace a bulb hanged at height H from the ground level.
In each case, there are B number of bulbs to be replaced by the electrician; each of which is hanged in the ceiling at different height Hi. Each time (case) the electrician uses a ladder of L meters in height and it is containing S number of steps that are distributed at equal distance from each. The number of step S includes the FIRST and the LAST step which are located at the bottom and top edge of the ladder.
To test your program, the length of the ladder (L) and the number of its steps (S), and the number of bulbs to be replaced (B) and their heights (Hi) from the ground level are given in a text file which contains M number of test cases given in the top of the input file. Then, for each test case the input file contains TWO lines: the first line contains length of the ladder (in meters), the number of steps in the ladder (maximum 99) and the number of bulbs (maximum 6) to be replaced. The second line contains the height (in centimeters) of each bulb from the ground level (see the sample input file)
Write a C++ program to read the input (which is described above) from a text file (say ladder.txt) and then counts the number of steps that the electrician must climb to replace each bulb in each case. If a bulb cannot be reached by the electrician then your program should display ‘N’ (to indicated Not-Possible). The program must also display the total number of bulbs replaced, the total number of bulbs not replaced, and the total number of steps that are climbed by the electrician in order to replace all reachable bulbs.

1. Assumption#1: The ladder is used vertically where the electrician must stand on the step that immediately passes the bottom of the bulb. So the program must count the steps up to that step.
2. Assumption#2: Your calculation should ignore the height of the electrician himself
3. Hint: A bulb is not reachable if the length of the ladder is less than the height of the bulb