program lights C*********************************************************************** C Given $150,000 how many traffic lights can be bought under the following C conditions: C 1. Each light is $5,000 C 2. Istallation is $1,000 C 3. Each light uses 420 kW-hrs per year C 4. $0.047 per kW-hr C************************************************************************ real lightcost, install, electusage, electcost real totcost, CostOfOne integer numlights lightcost = 5000.0 install = 1000.0 electusage = 420 electcost = electusage * 0.047 100 print *, 'How many lights do you think you can get for ', + '$150,000?' read *, numlights totcost = 0.0 CostOfOne = lightcost + install + electusage do 200 nlight = 1, numlights totcost = totcost + CostOfOne C print *, nlight, totcost 200 end do AmountLeft = 150000 - totcost if (AmountLeft .lt. 0) then print *, 'You overspent! Try Again.' goto 100 else if (AmountLeft .gt. CostOfOne) then print *, 'You could still buy more! You still have $', + AmountLeft,' to spend. Try Again.' goto 100 else print *, 'You Guessed it! You can by ', numlights, + ' stoplights for $150,000.' end if stop end