(The power station problem) A power station is on one side of a river
that is one-half mile wide, and a factory is eight miles downstream on the
other side of the river (see Figure 7-21). It costs $7 per foot to run power
lines over land and $9 per foot to run them under water. Your objective is
to determine the most economical path to lay the power line. That is,
determine how long the power line should run under water and how long
it should run over land to achieve the minimum total cost of laying the
power line.
Write a program that prompts the user to enter:
a. The width of the river
b. The distance of the factory downstream on the other side of the river
c. The cost of laying the power line under water
d. The cost of laying the power line over land
The program then outputs the length of the power line that should run
under water and the length that should run over land so the cost of
constructing the power line is at the minimum. The program should
also output the total cost of constructing the power line.

What have you tried so far, and what problems are you having with it? Please include at least enough of your source code to explain any difficulties you are experiencing.

Keep in mind the following DaniWeb community rule:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

And be aware that we will not do your homework for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.