Question: Problem: You have won a $ 1 0 0 gift certificate to buy your five favorite albums. The total cost of all albums must be
Problem: You have won a $ gift certificate to buy your five favorite albums. The total cost of all albums must be $ or less.
Modules Trying to Create:
main.
Calls inputAlbumCosts.
inputAlbumCosts. Uses a loop to input the costs of your five favorite albums. Accumulates the total cost as you input the price of each album.
Calls withinBudget.
withinBudget. Accepts the total cost of your albums and determines if you are within budget. Displays the total cost and displays a message indicating either that you are within budget or have exceeded $ limit
Calls averageCost.
averageCost. Accepts the total cost of the five albums. Calculates and displays the average cost of each album.
My Gaddis Pseudocode:
Module main
Declare Real totalCost
Set totalCost
Call inputAlbumCoststotalCost
Call withinBudgettotalCost
Call averageCosttotalCost
End Module
Module averageCost Real totalCost
Declare Real average
Set average totalCost
Display "The average cost of each album is: average
End Module
Module inputAlbumCosts Real totalCost
Declare Real albumCost
Declare Integer i
For i To
Display "Enter the cost of the album i:
Input albumCost
Set totalCost totalCost albumCost
End For
Call withinBudgettotalCost
End Module
Module withinBudget Real totalCost
Display "The total cost is $: totalCost
If totalCost Then
Display "This is within budget!"
Else
Display "You have exceeded the $ budget!"
End If
Call averageCosttotalCost
End Module
My Output:
Enter the cost of the album
Enter the cost of the album
Enter the cost of the album
Enter the cost of the album
Enter the cost of the album
The total cost is $:
This is within budget!
The average cost of each album is:
Output Trying to get:
Please enter the cost of album :
Please enter the cost of album :
Please enter the cost of album :
Please enter the cost of album :
Please enter the cost of album :
The total cost is $
This is within budget!
The average cost of each album is
Thank you for taking the time to read this long message. I am having trouble with my gaddis pseudocode getting the output I want. I have tried to rack my brain of what I did wrong in the code. How do I fix my gaddis pseudocode to get the output I am trying to get. I am missing something. The integer I and total value is not running the calculations. Thanks again.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
