bartborzeckiLabWeek4

bartborzeckiLabWeek4 - "" temp = Temp sum = temp...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Bart Borzecki CIS 170 k Instructor: Gross Week 4 Lab (Extra Credit) Lab4 Code //Lab4 for CIS170 – Bart Borzecki #include <iostream> using namespace ::std; int Temp(); void AverageTemp( int * sum, int * num); int main() { int temp = 0; int count = 0; int num = 1; double averageTemp = 0.0; int sum = 0; char answer; do { cout << "How many cities will you use: " ; cin >> count; while (count < 1) { cout << "Error! Invalid Input!" << endl; cout << "How many cities will you use: " ; cin.clear(); cin.ignore(); cin >> count; } num = 1; sum = 0; while (num <= count) { cout << "Please enter Temp " << num <<
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ":" ; temp = Temp(); sum += temp; num ++; } AverageTemp(&sum, &count); do { cout << "Do you want to do it again? (Y or N): " ; cin >> answer; answer = toupper(answer); } while (answer != 'Y' && answer != 'N' ); } while (answer == 'Y' ); } void AverageTemp( int * sum, int * count) { double averageTemp; averageTemp = static_cast < double >(*sum) / static_cast < double >(*count); cout << "The average is: " << averageTemp << endl; } int Temp() { int temp; cin >> temp; return temp; } Lab4 Output...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

bartborzeckiLabWeek4 - "" temp = Temp sum = temp...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online