Question: Assignment: The power station problem. Task: A power station is on one side of a river that is one-half mile wide, and a factory is
Assignment:
The power station problem.
Task:
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. 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.
Objectives:
Creating abstract code.
Creating code that is easier to read and modify/maintain.
Using functions.
Using constants.
Formatting output.
Using the modulus operator.
Specification:
Write a program that prompts the user to enter:
The distance of the factory downstream on the other side of the river.
The width of the river.
The cost of laying the power line over land.
The cost of laying the power line under water.
The program then determines and outputs the length of the power line that should run under water and the length that should run over land so that the cost of constructing the power line is at the minimum. The program should also output the total cost of constructing the power line.
You can make the following assumptions:
Move down the river in mile (1320) increments when determining the cost of laying the cable.
The power station and the factory are right next to the river.
You can disregard the z axis (the depth of the cable) when determining the cost.
Requirements:
Your code should:
Use functions whenever possible.
Use constants when warranted.
Cable length should be displayed in miles to 4 decimal places.
Dollar amounts should be preceded by a dollar sign ($) to 2 decimal places.
Output:
Your output shall:
List the cable length going over land and its cost with an appropriately written prompt that identifies what the length and cost represents.
List the cable length going across the river and its cost with an appropriately written prompt that identifies what the length and cost represents.
List the overall cost to lay the cable with an appropriately written prompt that identifies what the cost represents.
The execution of your program should be exactly as the output below:
Enter the distance downstream to the factory in miles: 8
Enter the width of the river in miles: .5
Enter the dollar cost per foot to run power over land: 7
Enter the dollar cost per foot to run power under water: 9
The most cost effective solution is:
Lay power line across land for 7.2500 miles at a cost of $267960.00.
Lay power line under water for 0.9015 miles at a cost of $42833.95.
The total cost = $310793.95.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
