PRG 211
January 11, 2012
University of Phoenix
Array Structure
The purpose of the parallel array structure is to hold 2 different elements of information on budget numbers for each month. I created two parallel arrays one to hold the budget scheduled amount and another array to hold the budgeted amount that was achieved. Each array will hold information for each month. If I created this by using inputs without arrays, I would have had to create 24 different input statements to hold the 24 different elements of information. Using the array was much each and quicker. I just needed to create a loop with an end value of 12, which represented the 12 months of the year. Each pass through the loop, the month would change and I was able to enter both the scheduled budgeted information and the achieved budget. Once the loop was completed, the array was filled with information. …show more content…
In order to output the information, I created a second for loop to be able to output each month has moved through the second loop.
I was able to do this by creating three if decision trees that determined whether the budgeted quota was equal, over, or under budget, then i output the information to the console for each time through the loop. I used the console instead of the screen to be able to output more than 1 line for each loop. This way it shows all 12 months of data for both budgets arrays in one Output window. If I would have done this without using arrays and loops, I would have had to create 3 decision trees with 3 outputs for each of the 12 months which would have taken much more time and more likely to make a mistake. In conclusion I would state that by using arrays, it makes it much easier to store and retrieve information into the different elements of the
array.
Here is a copy of the pseudocode that I will be using to create the program.
//Make Array BudgetQuota to hold 12 months of the scheduled budget quota
Make Array (BudetQuota,12)
//Make Array Quota to hold 12 months of the Quota
Make Array(Quota, 12)
//Set Month Count to Count 12 months to fill arrays
Month_Counts 1 to 12
//Input BudgetQuota for 12 months
Input BudgetQuota (Month_Counts)
//Input Quota for 12 months
Input Quota(Month_Counts)
//Count 12 months to display Output all the months
//If the BudgetQuota is greater than Quota than budget quota is under budget
//If the BudgetQuota is equal to Quota than budget quota is on budget
//If the BudgetQuota is less than Budget than the budget quota is over budget
If BudgetQuota(MonthCount)>Quota(MonthCount)
Then Display “Your Quota of “&Quota(MonthCount)”is under Budget of the budgeted quota of “&BudgetQuota(MonthCount)”for month”&MonthCount
End If
If BudgetQuota(MonthCount)<Quota(MonthCount)
Then Display “Your Quota of “&Quota(MonthCount)”is over Budget of the budgeted quota of “&BudgetQuota(MonthCount)”for month”&MonthCount
End If
If BudgetQuota(MonthCount=Quota(MonthCount)
Then Display “Your Quota of “&Quota(MonthCount)”is on Budget of the budgeted quota of “&BudgetQuota(MonthCount)”for month”&MonthCount
End If