The cost of sending a package by an express delivery sercise is $12.00 for the f
ID: 3626425 • Letter: T
Question
The cost of sending a package by an express delivery sercise is $12.00 for the first 2 pounds, and $4.00 for each pound or fraction thereof over 2 pounds. If the package weights more than 70 pounds, a $10 excess weight surcharge is added to the cost. No package over 100 pounds will be accepted. Write a fortran program that accepts the weight of a package in pounds and computers the cost of mailing the package. Be sure to handle the case of overweight packages.
one using IF-THEN-ELSE constructs and another alternative solution using SELECT CASE construct. Submit printout of program along with output based on sample input that will test each code block.
Thank you
Explanation / Answer
PROGRAM MailingCost
IMPLICIT NONE
REAL :: weight,cost
!Reading weight
READ(*,*)weight
SELECT CASE (weight)
CASE (1:2)
cost=12
WRITE(*,*) 'Mail cost:$ ',cost
CASE(3:70)
cost=12+(weight-2)*4
WRITE(*,*) 'Mail cost:$ ',cost
CASE(70:100)
cost=12+(weight-2)*4+(weight-70)*10
WRITE(*,*) 'Mail cost:$ ',cost
CASE DEFAULT
WRITE(*,*) 'Over weight Mailing not possible'
END SELECT
END PROGRAM MailingCost
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.