In: Computer Science
Write the Flowchart for the following programming problem based on the pseudocode below.
Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the energy difference from the two years and display the two years’ worth of data, along with the savings.
Hints: Create three arrays of size 12 each. The first array will store the first year of energy costs, the second array will store the second year after going green, and the third array will store the difference. Also, create a string array that stores the month names. These variables might be defined as follows:
notGreenCost = [0] * 12
goneGreenCost = [0] * 12
savings = [0] * 12
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
Your sample output might look as follows:
Enter NOT GREEN energy costs for January
Enter now -->789
Enter NOT GREEN energy costs for February
Enter now -->790
Enter NOT GREEN energy costs for March
Enter now -->890
Enter NOT GREEN energy costs for April
Enter now -->773
Enter NOT GREEN energy costs for May
Enter now -->723
Enter NOT GREEN energy costs for June
Enter now -->759
Enter NOT GREEN energy costs for July
Enter now -->690
Enter NOT GREEN energy costs for August
Enter now -->681
Enter NOT GREEN energy costs for September
Enter now -->782
Enter NOT GREEN energy costs for October
Enter now -->791
Enter NOT GREEN energy costs for November
Enter now -->898
Enter NOT GREEN energy costs for December
Enter now -->923
-------------------------------------------------
Enter GONE GREEN energy costs for January
Enter now -->546
Enter GONE GREEN energy costs for February
Enter now -->536
Enter GONE GREEN energy costs for March
Enter now -->519
Enter GONE GREEN energy costs for April
Enter now -->493
Enter GONE GREEN energy costs for May
Enter now -->472
Enter GONE GREEN energy costs for June
Enter now -->432
Enter GONE GREEN energy costs for July
Enter now -->347
Enter GONE GREEN energy costs for August
Enter now -->318
Enter GONE GREEN energy costs for September
Enter now -->453
Enter GONE GREEN energy costs for October
Enter now -->489
Enter GONE GREEN energy costs for November
Enter now -->439
Enter GONE GREEN energy costs for December
Enter now -->516
-------------------------------------------------
SAVINGS
_____________________________________________________
SAVINGS NOT GREEN GONE GREEN MONTH
_____________________________________________________
$ 243 $ 789 $ 546 January
$ 254 $ 790 $ 536 February
$ 371 $ 890 $ 519 March
$ 280 $ 773 $ 493 April
$ 251 $ 723 $ 472 May
$ 327 $ 759 $ 432 June
$ 343 $ 690 $ 347 July
$ 363 $ 681 $ 318 August
$ 329 $ 782 $ 453 September
$ 302 $ 791 $ 489 October
$ 459 $ 898 $ 439 November
$ 407 $ 923 $ 516 December
Do you want to end program? (Enter no or yes): yes
The Pseudocode
Module main()
//Declare local variables
Declare endProgram = “no”
While endProgram == “no”
Declare Real notGreenCost[12]
Declare Real goneGreenCost[12]
Declare Real savings[12]
Declare String months[12] = “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”
//function calls
getNotGreen(notGreenCost, months)
getGoneGreen(goneGreenCost, months)
energySaved(notGreenCost, goneGreenCosts, savings)
displayInfo(notGreenCost, goneGreenCosts, savings, months)
Display “Do you want to end the program? Yes or no”
Input endProgram
End While
End Module
Module getNotGreen(Real notGreenCost[], String months[])
Set counter = 0
While counter < 12
Display “Enter NOT GREEN energy costs for”, months[counter]
Input notGreenCosts[counter]
Set counter = counter + 1
End While
End Module
Module getGoneGreen(Real goneGreenCost[], String months[])
Set counter = 0
While counter < 12
Display “Enter GONE GREEN energy costs for”, months[counter]
Input goneGreenCosts[counter]
Set counter = counter + 1
End While
End Module
Module energySaved(Real notGreenCost[], Real goneGreenCost[], Real savings[])
Set counter = 0
While counter < 12
Set savings[counter] = notGreenCost[counter] – goneGreenCost[counter]
Set counter = counter + 1
End While
End Module
Module displayInfo(Real notGreenCost[], Real goneGreenCost[], Real savings[], String months[])
Set counter = 0
While counter < 12
Display “Information for”, months[counter]
Display “Savings $”, savings[counter]
Display “Not Green Costs $”, notGreenCost[counter]
Display “Gone Green Costs $”, goneGreenCost[counter]
End While
End Module