// Begin Psuedocode Design // Author: Liam Smith // Date: 02/03/06 // Version: Assignment 1 Pseudocode Design // Lecturer: Digby Barrett & Kim Ng // Objective: Read in temperatures in "celcius" for every day in January. // Promt the user with the day number: // e.g. "Enter temperature for day 1:" // // Print the average of all temperatures over 30 degrees, // the average of all temperatures between 20 and 30 // degrees, andthe average of all temperatures below 20 // degrees. for day = 1 to 31 write("Enter Temperature") read(temp) if(temp = less20) belowtot=belowtot+temp belowav+1 end if else if(temp = 20 to 30) betweentot=betweentot+temp betweenav+1 end if else if(temp = more30) overtot=overtot+temp overav+1 end if end for belowtot=belowtot/belowav betweentot=betweentot/betweenav overtot=overtot/overav write("Days below 20 = [belowav]") write("Average temperature below 20 = [belowtot]") write("Days between 20 and 30 = [betweenav]") write("Average temperature between 20 and 30 = [betweentot]") write("Days above 30 = [overav]") write("Average temperature above 30 = [overtot]") // End Psuedocode Design // Begin CPP Code // Author: Liam Smith // Date: 02/03/06 // Version: 1.1 // Lecturer: Digby Barrett & Kim Ng // Objective: Read in temperatures in "celcius" for every day in January. // Promt the user with the day number: // e.g. "Enter temperature for day 1:" // // Print the average of all temperatures over 30 degrees, the // average of all temperatures between 20 and 30 degrees, and // the average of all temperatures below 20 degrees. #include int main() { // Identifiers and their values. int temp=0, day=1, overtot=0, betweentot=0, belowtot=0, overav=0, betweenav=0, belowav=0; // "For" loop continues while the day value is less than or equal to 31, each // time it loops it adds 1 to the day value. for (day;day<=31;day++) { // "cout" display's a promt or a message, "cin" allows the user to input data. cout<<"\n Enter temperature for day "<>temp; // "if" gives a condition, if the condition is true an action is performed and // the "for" loop is repeated, with a "cout" promt. if (temp<20) {belowtot=belowtot +temp; belowav++;} // "else" tests the next "if" condition, only if the previous "if" was false. else if (temp>=20 && temp<=30) {betweentot=betweentot +temp; betweenav++;} else if (temp>30) {overtot=overtot +temp; overav++;} } belowtot=belowtot/belowav; betweentot=betweentot/betweenav; overtot=overtot/overav; cout<<"\n ------------------------------------------------------------"; cout<<"\n Days with temperatures below 20 ="<