Question: Variable not initialized: The variable 'totalCost' was not initialized. How do I fix this to make the program run. Psuedocode: Module main ( ) Declare

Variable not initialized: The variable 'totalCost' was not initialized. How do I fix this to make the program run.
Psuedocode:
Module main()
Declare Real totalCost
Call calculateAlbumCosts(totalCost)
Call displayCostAndBudget(totalCost)
End Module
Module calculateAlbumCosts (Real totalCost)
Declare Real albumCost, totalCost
Declare Integer i
Set totalCost =0
Display "Enter the cost of album: "
Input albumCost
For i =1 To 5
Set totalCost = totalCost + albumCost
End For
Call displayCostAndBudget(totalCost)
End Module
Module displayCostAndBudget (Real totalCost)
Declare Real totalCost
Display "The total cost is $: ", totalCost
If totalCost <=100 Then
Display "This is within budget!"
Else
Display "You are over budget!"
End If
End Module

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!