Question
Write a program using arrays that accepts sales amount of the day for six days. The program will compute total sales and will display it.
Write a program using arrays that accepts sales amount of the day for six days. The program will compute total sales and will display it.
Psuedo-code:
// Main module
Module Main()
// Create an array to hold the sales for six days.
Constant Integer SIZE = 6
Declare Real sales[SIZE]
// Get the sales.
Call getSales(sales, SIZE)
// Display the total sales.
Call showTotal(sales, SIZE)
End Module
// getSales module
Module getSales(Real Ref sales[], Integer size)
Declare Integer index // Loop counter
// Get the sales for a week.
For index = 0 To size - 1
Display "Enter the sales for day #", index + 1
Input sales[index]
End For
End Module
// showTotal module
Module showTotal(Real sales[], Integer size)
Declare Integer index // Loop counter
Declare Real total = 0 // Accumulator
// Calculate the total.
For index = 0 To size - 1
total = total + sales[index]
End For
// Display the total.
Display "The total sales are ", total
End Module
-------------------------------------------------------------------------------------------------------------
Flowchart
Flowchart of the Sales Problem: getSales Real Ref sales0, Integer size) main0 Constant Integer SIZE 6 Declare Integer sales[SIZE] Declare Integerindex Call getSales sales, SIZE) Set index = 0 Call showTotal sales, SIZE) False index True size-1 End Display "Enter the sales for day #", index + 1 " Return Input sales[index]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started