main module Module main() // Local variables Declare Real weight, shipping // Get package weight Call getWeight(weight) // Calculate the shipping charge Call setShipping(weight, shipping) // Display shipping charge Call showShipping(shipping)
// main module
Module main()
// Local variables
Declare Real weight, shipping
// Get package weight
Call getWeight(weight)
// Calculate the shipping charge
Call setShipping(weight, shipping)
// Display shipping charge
Call showShipping(shipping)
End Module
// The getWeight module gets package weight and stores it
// in the inputWeight reference variable.
Module getWeight(Real Ref inputWeight)
Display “Enter package weight: ”
Input inputWeight
End Module
// The setShipping module sets the shipping charge and stores it
// in the calcShipping reference variable.
Module setShipping(Real weight, Ref calcShipping)
If weight > 10 Then
Set calcShipping = 3.80
Else
If weight > 6 Then
Set calcShipping = 3.70
Else
If weight > 2 Then
Set calcShipping = 2.20
Else
Set calcShipping = 1.10
End If
End Module
// The showShipping module accepts shipping as argument
// and displays the amount
Module showShipping(Real shipping)
Display "Shipping charge: $", shipping
End Module
I want to learn about
Trending now
This is a popular solution!
Step by step
Solved in 2 steps