Moloch
12-19-2008, 02:11 AM
Quick synopsis I'm on my final exam for college. I have a few questions that have me puzzled.
Assume an array named salesData[] contains a company's sales figures for the last twelve months. The following is the (partial) pseudocode for a program that uses an accumulator (totalSales), a counter (monthNumber), a loop to sum all the elements in the array, and uses the sum to find the average sales figures over the last 12 months. (Assuming not zero based)
Part A: fill in the missing elements of the pseudocode (15 points)
totalSales = ___________
for monthNumber = 1 to ___12_______ //this was np
totalSales = ___________ + salesData[ ___________ ]
endfor
salesAverage = ____totalSales________ divided by 12 //this part easy
Part B: Code a second loop to determine how many months the sales exceed the average and then output that value. (10 points)
The following pseudocode for the logic of a program does the following:
1) Prompts the user to input a savings account balance and inputs that balance.
2) Prompts the user to enter the annual interest rate for the account and inputs the interest rate.
3) If the interest rate was not entered in decimal form, it converts it to a decimal.
4) Calculates twice the current balance and set this equal to the target balance;
5) Initializes the year counter that will keep track of the number of years it takes.
6) Calculates the balance of the account as it continues to earn interest until the balance in the account has reached or exceeded the target balance (each year the new balance is equal to the old balance plus the old balance times the interest rate);
7) Output the number of years it takes to reach the target balance.
Note: each row (1-7) in the table given below refers to the description (1 - 7) given above.
output _______________
input balance
output _______________
input rateOfReturn
if rateOfReturn >= 1 then
rateOfReturn = _____________ divided by 100
_________
targetBalance = 2 _________ balance
yearCounter = _____________
while balance < targetBalance
____________ = ____________ + balance times rateOfReturn
yearCounter = ______________
endwhile
output "It will take " + ____________ + "years to double your balance."
Any help would be greatly appreciated.
Please delete this post after 1.5 hours
Assume an array named salesData[] contains a company's sales figures for the last twelve months. The following is the (partial) pseudocode for a program that uses an accumulator (totalSales), a counter (monthNumber), a loop to sum all the elements in the array, and uses the sum to find the average sales figures over the last 12 months. (Assuming not zero based)
Part A: fill in the missing elements of the pseudocode (15 points)
totalSales = ___________
for monthNumber = 1 to ___12_______ //this was np
totalSales = ___________ + salesData[ ___________ ]
endfor
salesAverage = ____totalSales________ divided by 12 //this part easy
Part B: Code a second loop to determine how many months the sales exceed the average and then output that value. (10 points)
The following pseudocode for the logic of a program does the following:
1) Prompts the user to input a savings account balance and inputs that balance.
2) Prompts the user to enter the annual interest rate for the account and inputs the interest rate.
3) If the interest rate was not entered in decimal form, it converts it to a decimal.
4) Calculates twice the current balance and set this equal to the target balance;
5) Initializes the year counter that will keep track of the number of years it takes.
6) Calculates the balance of the account as it continues to earn interest until the balance in the account has reached or exceeded the target balance (each year the new balance is equal to the old balance plus the old balance times the interest rate);
7) Output the number of years it takes to reach the target balance.
Note: each row (1-7) in the table given below refers to the description (1 - 7) given above.
output _______________
input balance
output _______________
input rateOfReturn
if rateOfReturn >= 1 then
rateOfReturn = _____________ divided by 100
_________
targetBalance = 2 _________ balance
yearCounter = _____________
while balance < targetBalance
____________ = ____________ + balance times rateOfReturn
yearCounter = ______________
endwhile
output "It will take " + ____________ + "years to double your balance."
Any help would be greatly appreciated.
Please delete this post after 1.5 hours